Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function analyzeImage(doc, fileName, analyzeCallback) {
console.log("Starting Analyze Image Method");
var
request = require('request'),
async = require('async'),
fs = require('fs'),
gm = require('gm').subClass({
imageMagick: true
}),
analysis = {};
async.parallel([
function (callback) {
// Write down meta data about the image
gm(fileName).size(function (err, size) {
if (err) {
console.log("Image size", err);
} else {
analysis.size = size;
}
callback(null);
});
},let express = require('express'),
fs = require('fs'),
fse = require('fs-extra'),
mkdirP = require('mkdirp'),
multer = require('multer'),
crypto = require('crypto'),
mime = require('mime'),
path = require('path'),
config = require('../config/config'),
User = require('../models/user.model'),
Form = require('../models/form.model'),
gm = require('gm').subClass({imageMagick: true});
process.on('uncaughtException', (err) => {
console.log(err);
});
// this function deletes the image
let rmDir = (dirPath, removeSelf) => {
if (removeSelf === undefined)
removeSelf = true;
try {
var files = fs.readdirSync(dirPath);
}
catch (e) {
return;
}
if (files.length > 0)import fs from 'fs'
import path from 'path'
import gm from 'gm'
import spawn from 'cross-spawn'
import mkdirp from 'mkdirp'
import tmp from 'tmp'
const gmMagick = gm.subClass({ imageMagick: true })
function transparent(filename, options) {
if (!options.width || !options.height) {
throw new Error('Wrong options provided to transparent()')
}
const gmImage = gmMagick(filename)
gmImage.background('transparent') // Fill in new space with white background
gmImage.gravity('NorthWest') // Anchor image to upper-left
gmImage.extent(options.width, options.height) // Specify new image size
return gmImage
}
function getImageSize(filename) {
return new Promise((accept, reject) => {// image operation.
var
fs = require('fs'),
gm = require('gm').subClass({ imageMagick : true });
function calcScaleSize(origin_width, origin_height, resize_width, resize_height, keepAspect) {
function isEnlarge(tw, th) {
return origin_width < tw && origin_height < th;
}
if (resize_width <= 0 && resize_height <= 0) {
throw {"name": "Parameter error!"};
}
if (keepAspect === undefined) {
keepAspect = true;
}
if (origin_width === resize_width && origin_height === resize_height) {
return { width: origin_width, height: origin_height, resized: false, enlarge: false };
}
varconst farmhash = require("farmhash");
const imageinfo = require("imageinfo");
let gm = require("gm");
const async = require("async");
const models = require("../lib/models");
const urls = require("../lib/urls");
const db = require("../lib/db");
const similar = require("../lib/similar");
const config = require("../lib/config");
// Add the ability to provide an explicit bath to the GM binary
/* istanbul ignore if */
if (config.GM_PATH) {
gm = gm.subClass({appPath: config.GM_PATH});
}
const Image = new db.schema({
// An ID for the image in the form: SOURCE/IMAGENAME
_id: String,
// The date that this item was created
created: {
type: Date,
default: Date.now,
},
// The date that this item was updated
modified: {
type: Date,
},'use strict';
const gm = require('gm').subClass({imageMagick: true});
const _ = require('lodash');
const fs = require('fs');
const os = require('os');
const mkdirp = require('mkdirp');
const child_process = require('child_process');
const async = require('async');
let OUT_DIR = os.tmpDir() + '/app-icon/output';
const androidIconSize = {
// 'web': { w: 512, h: 512 },
'ldpi': { w: 36, h: 36 },
'mdpi': { w: 48, h: 48 },
'hdpi': { w: 72, h: 72 },
'xhdpi': { w: 96, h: 96 },var express = require('express'),
router = express.Router(),
passwordHash = require('password-hash'),
jwt = require('jsonwebtoken'),
config = require('../config/config'),
fs = require('fs'),
multer = require('multer'),
mime = require('mime'),
path = require('path'),
crypto = require("crypto"),
gm = require('gm').subClass({imageMagick: true});
var User = require('../models/user.model');
// user register
router.post('/register', function (req, res, next) {
var user = new User({
email: req.body.email,
password: passwordHash.generate(req.body.password)
});
user.save(function (err, result) {
if (err) {
return res.status(403).json({
title: 'There was an issue',
error: {message: 'The email you entered already exists'}
});
}'use strict';
/**
* image operation.
*
* ImageMagick MUST be installed first.
*
* author: Michael Liao
*/
const
bluebird = require('bluebird'),
api = require('./api'),
logger = require('./logger'),
gm = require('gm').subClass({ imageMagick : true });
function calcScaleSize(origin_width, origin_height, resize_width, resize_height, keepAspect) {
function isEnlarge(tw, th) {
return origin_width < tw && origin_height < th;
}
if (resize_width <= 0 && resize_height <= 0) {
throw new Error('invalid parameter: ' + resize_width + ', ' + resize_height);
}
if (keepAspect === undefined) {
keepAspect = true;
}
if (origin_width === resize_width && origin_height === resize_height) {
return { width: origin_width, height: origin_height, resized: false, enlarge: false };
}
letlet express = require('express'),
User = require('../models/user.model'),
jwt = require('jsonwebtoken'),
config = require('../config/config'),
fs = require('fs'),
multer = require('multer'),
mime = require('mime'),
path = require('path'),
crypto = require('crypto'),
gm = require('gm').subClass({imageMagick: true}),
nodemailer = require('nodemailer'),
hbs = require('nodemailer-express-handlebars'),
sgTransport = require('nodemailer-sendgrid-transport'),
uuidV1 = require('uuid/v1'),
async = require('async');
function generateToken(user) {
return jwt.sign(user, config.secret, {expiresIn: config.jwtExpire});
}
function setUserInfo(req) {
return {
_id : req._id,
email: req.email,
role : req.role
};"use strict";
var multer = require("multer");
var fs = require("fs");
var gm = require("gm").subClass({ imageMagick: true });
var path = require("path");
var imagePath = "./server/static/images/";
var upload = multer({ dest: imagePath });
/**
* Creating directory for specific image size if not exists
* requires npm "fs" module.
*/
function createDirIfNotExists(path){
if (!fs.existsSync(path)){
fs.mkdirSync(path);
}
}