2

在我的应用程序中,我尝试使用 imagemagick 调整图像大小,但在调整大小时出现以下错误错误:imagesexecvp(): No such file or directory.this is my code

   im.resize({
  srcPath:  '/tmp/Images/' + req.files.image.name,
  dstPath: 'resized_'+req.files.image.name ,
  width:42,
  height:42
}, function(err, stdout, stderr){
  if (err) {

      console.log('error while resizing images' + stderr);
  };
});
4

4 回答 4

2

imagemagick 模块使用convertandidentify命令,您描述的错误可能会发生,因为找不到命令。确保命令位于路径环境变量引用的文件夹中,或者您可以在节点应用程序中引用命令:

var im = require('imagemagick');    
im.identify.path = '/opt/ImageMagick/bin/identify'
im.convert.path = '/opt/ImageMagick/bin/convert';
于 2013-01-21T15:58:15.743 回答
0

看起来您正在尝试在不更改目标的情况下调整文件大小。试试这个:

im.resize({
  srcPath:  process.cwd() + '/tmp/Images/' + req.files.image.name,
  dstPath:  process.cwd() + '/tmp/Images/resized_'+req.files.image.name ,
  width:42,
  height:42
}, function(err, stdout, stderr){
  if (err) {
      console.log('error while resizing images' + stderr);
  };
  console.log( process.cwd() + '/tmp/Images/' + req.files.image.name + 'has been resized and saved as ' + process.cwd() + '/tmp/Images/resized_'+req.files.image.name)
});

您还可以检查您的权限 (ls -l)/tmp/Images/以确保它们设置正确

于 2012-09-26T01:07:55.933 回答
0

您需要安装图像魔术命令行工具。尝试brew install imagemagick

于 2013-01-23T11:27:46.070 回答
0

如果您在 ubuntu 上,请像这样安装软件包:

apt-get install imagemagick

之后,再试一次:D

于 2013-02-12T23:10:41.617 回答