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

随声附和 提交于 2020-01-04 01:57:29

问题


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?


回答1:


Replace:

var gm = require('gm');

for

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



回答2:


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

sudo port install GraphicsMagick

It will install GraphicsMagick library.



来源:https://stackoverflow.com/questions/22930506/nodejs-error-spawn-enoent-while-adjusting-image-size-using-module-gm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!