2016-03-15 135 views
1

不僅我有這樣的問題:Node js + imagemagick + Error: spawn ENOENTImageMagick的ENOENT錯誤

console.log(appPath + '/public/avatar/tmp_' + filename); 
var path = appPath + '/public/avatar/tmp_' + filename; 
try { 
    fs.accessSync(path, fs.F_OK); 
    // Do something 
    console.log('file exists!'); 
} catch (e) { 
    // It isn't accessible 
    console.log('file does NOT exist!'); 
} 

console.log('trying...'); 
// crop/resize image 
im.crop({ 
    srcPath: path, 
    dstPath: 'test1.png', 
    width: 60, 
    height: 60 
}, function(err, stdout, stderr){ 
    console.log('here'); 
    if (err) { 
     console.log('trololololol '+err); 
     reject(err); 
    } 
    console.log('resized to fit within 60x60px'); 
    resolve(); 
}); 

我得到的控制檯輸出:

C:\www\instantynode\src/public/avatar/tmp_1458064183594_la5v9vcuc27hw7b9.png 
file exists! 
trying... 
events.js:141 
     throw er; // Unhandled 'error' event 
    ^

Error: spawn identify ENOENT 
    at exports._errnoException (util.js:870:11) 
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32) 
    at onErrorNT (internal/child_process.js:344:16) 
    at nextTickCallbackWith2Args (node.js:442:9) 
    at process._tickCallback (node.js:356:17) 

回答

5

ENOENT意味着identify無法找到。確保已安裝ImageMagick,並且它安裝在$PATH中的路徑中。

+1

我有同樣的問題,我已經安裝imagemagick使用npm安裝imagemagick - 不清理我現在要做的。 –

0

我也有這個錯誤,我所做的就是做imagemagick.exe的副本在安裝目錄下(這是C:\ Program Files文件\ ImageMagic我)和重命名的文件,以identify.exe