How to use the gm.resize function in gm

To help you get started, we’ve selected a few gm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github danactive / history / js / admin-image-manipulation.js View on Github external
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);
				});
			}
github sinizinairina / eviltext / modules / image-processor.js View on Github external
_(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)

gm

GraphicsMagick and ImageMagick for node.js

MIT
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis