简体   繁体   中英

nodejs - Error: spawn ENOENT while adjusting image size using module gm

I am trying to create a thumbnail with an image that I have already saved. I am using the module gm to adjust the size of the image.

var gm = require ('gm');
var fs = require('fs');
var savedphoto = "./testphoto.jpeg";
var testdir = "./testoutput.jpeg";
gm(savedphoto)
    .resize(100, 100)
    .noProfile()
    .write(testdir, function (err) {
        console.error (err);
    });

When I run this I get the error spawn ENOENT .

code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn. 

How would I fix this problem?

Replace:

var gm = require('gm');

for

var gm = require('gm').subClass({ imageMagick: true });

Recipe for MacPorts users only (based on @RevNoah notice):

sudo port install GraphicsMagick

It will install GraphicsMagick library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM