我正在尝试在将图像提供给客户端之前调整图像大小。在我的公共目录中,我有目录images
。所有图像都通过独特的永久链接成功提供给不同的页面。 http://localhost:3000/post/
+ permalink
。我npm安装了gm,imagemagick,并尝试了brew install imagemagick。我在我的路线文件中有这个:
var p = 'post/'+permalink
console.log(p);
var fs = require('fs');
var gm = require('gm').subClass({ imageMagick: true });
gm('images/black-yellow-simple-lady-woman.jpg')
.resize(234, 567)
.autoOrient()
.write(p, function (err) {
if (err) console.log(' noooo! '+err);
});
Error: Command failed: convert: unable to open image `images/black-yellow-simple-lady-woman.jpg': No such file or directory @ error/blob.c/OpenBlob/2643.
convert: no images defined `post/ribs_52977588145822' @ error/convert.c/ConvertImageCommand/3127.
答案 0 :(得分:1)
请将您的相对路径gm(' images / black-yellow-simple-lady-woman.jpg')更改为绝对' / home / user / meteorproject / public / images / black-黄简单女士-woman.jpg'