Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
format = "jpg";
} else if (/PNG/i.test(format)) {
format = "png";
} else {
throw new Error("Unrecognized iTunes Artwork format: \"" + format +'"')
}
var args = req.parsedUrl.query;
if (args) {
if (args.size) args.width = args.height = args.size;
this.parallel()(null, args.format || format);
args.srcData = rawData.toString('binary');
args.srcFormat = format;
args.format = args.format || format;
delete args.dstPath;
im.resize(args, this.parallel());
} else {
// No query params given, just send the original image data.
this.parallel()(null, format);
this.parallel()(null, rawData);
}
},
function(err, format, rawData) {
Object.keys(options.imageVersions).forEach(function (version) {
counter += 1;
var opts = options.imageVersions[version];
imageMagick.resize({
width: opts.width,
height: opts.height,
srcPath: options.uploadDir + '/' + fileInfo.name,
dstPath: options.uploadDir + '/' + version + '/' +
fileInfo.name
}, finish);
});
}
Object.keys(options.imageVersions).forEach(function (version) {
counter += 1;
var opts = options.imageVersions[version];
imageMagick.resize({
width: opts.width,
height: opts.height,
srcPath: options.uploadDir + '/' + fileInfo.name,
dstPath: options.uploadDir + '/' + version + '/' +
fileInfo.name
}, finish);
});
}
Object.keys(options.imageVersions).forEach(function (version) {
if (!_existsSync(options.uploadDir + '/' + version + '/'))
throw new Error(options.uploadDir + '/' + version + '/' + ' not exists');
counter++;
var opts = options.imageVersions[version];
imageMagick.resize({
width: opts.width,
height: opts.height,
srcPath: options.uploadDir + '/' + fileInfo.name,
dstPath: options.uploadDir + '/' + version + '/' + fileInfo.name
}, finish);
});
}
Object.keys(options.imageVersions).forEach(function (version) {
counter += 1;
var opts = options.imageVersions[version];
imageMagick.resize({
width: opts.width,
height: opts.height,
srcPath: options.uploadDir + '/' + fileInfo.name,
dstPath: options.uploadDir + '/' + version + '/' +
fileInfo.name
}, finish);
});
}
Object.keys(options.imageVersions).forEach(function (version) {
counter += 1;
var opts = options.imageVersions[version];
imageMagick.resize({
width: opts.width,
height: opts.height,
srcPath: options.uploadDir + '/' + fileInfo.name,
dstPath: options.uploadDir + '/' + version + '/' +
fileInfo.name
}, finish);
});
}
function doResize() {
magick.resize(opt, function(err) {
//** imagemagick wont create directories (yet), so a failure in creating images usually means directories are missing...
!!err ? def.reject(err) : def.resolve();
});
}
function resize(data, cb) {
require('imagemagick').resize({
srcData: data,
width: RESIZED_WIDTH
}, function(err, out) {
if (err) { return cb(err); }
cb(null, new Buffer(out, 'binary'));
});
}
resize : function(args, next) {
imagemagick.resize(args, next);
},