I'm trying to resize images before serving them to the client. Inside my public directory I have the directory images. All images are being served to different pages successfully with unique permalinks. http://localhost:3000/post/+permalink. I npm installed gm, imagemagick, and tried brew install imagemagick as well. I have this in my routes files:
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.
gm()with the absolute image path.