Graphicsmagick for node not writing the whole jpg

后端 未结 4 1867
独厮守ぢ
独厮守ぢ 2021-01-14 03:40

I am using https://github.com/aheckmann/gm to resize an image.

var fs = require(\'fs\');
var gm = require(\'gm\');

var input = __dirname   + \'/input.jpg\';         


        
4条回答
  •  臣服心动
    2021-01-14 04:15

    I found imagemagick very useful and simple. I also tried graphicsmagick but no luck.

    You can install imagemagick with the following command.

    npm install imagemagick
    

    Following is the example code and documentation for imagemagick is at https://github.com/rsms/node-imagemagick:

    var im = require('imagemagick');
    
    im.resize({
      srcPath: 'kittens.jpg',
      dstPath: 'kittens-small.jpg',
      width: 50,
      height: 50
    }, function(err, stdout, stderr){
      if (err) throw err;
      console.log('resized kittens.jpg to fit within 256x256px');
    });
    

提交回复
热议问题