Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (errorNewPath) {
throw errorNewPath;
}
if (require('fs').existsSync(outputPath + filename)) { // file exists
if (constant.config.debug && constant.config.debug === true) {
console.log("createThumb: file exists:" + outputPath + filename + ";");
}
afterThumbCreated();
return;
}
if (constant.config.debug && constant.config.debug === true) {
console.log("ifImage resize image: filename="+filename+";");
}
require('gm')(sourcePath + filename)
.resize(dimension.width, dimension.height + ">")
.gravity('Center')
.extent(dimension.width, dimension.height)
.write(outputPath + filename, afterThumbCreated);
});
}
_(sizes).asyncEach(function(sizeAliasAndFormat, i, ecb, next){
var sizeAlias = sizeAliasAndFormat[0]
var sizeFormat = sizeAliasAndFormat[1]
var targetPath = app.pathUtil.join(buildDir, resizedTarget(file, sizeAlias))
app.ensurePathInBuildDirectory(targetPath)
app
require('gm')(originalPath)
.resize(sizeFormat.width, sizeFormat.height, sizeFormat.format)
.autoOrient()
.noProfile()
.write(targetPath, _.fork(function(err){
// If no GraphicsMagick installed, just copying the same image.
if(err.syscall == 'spawn' && err.code == 'ENOENT'){
warnAboutGraphicMagicOnce()
app.copyFile(originalPath, targetPath, ecb, next)
}else ecb(err)
}, next))
}, ecb, function(){
app.copyFile(originalPath, app.pathUtil.join(buildDir, originalTarget(file)), ecb, cb)