nodejs - 错误:使用模块gm调整图像大小时生成ENOENT [英] nodejs - Error: spawn ENOENT while adjusting image size using module gm

查看:175
本文介绍了nodejs - 错误:使用模块gm调整图像大小时生成ENOENT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用我已保存的图片创建缩略图。我使用模块 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);
    });

当我运行这个时,我得到错误spawn ENOENT

When I run this I get the error spawn ENOENT.

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

我如何解决这个问题?

How would I fix this problem?

推荐答案

替换:

var gm = require('gm');

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

这篇关于nodejs - 错误:使用模块gm调整图像大小时生成ENOENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆