Linux – how to properly set up ImageMagick on AWS server using nodejs and express

imagemagicklinuxnode.js

so basically I've been struggling for a while now on getting imagemagick and or graphicsmagick to run properly with my node app, so far I followed the installation source from http://www.imagemagick.org/script/install-source.php#unix.

details on my server include

-nodejs
-mongodb
-mongoose
-imagemagick
-graphicsmagick
-express

and it seems the installation went well, however when I run the code through node with gm (https://npmjs.org/package/gm) I don't get any errors but the files don't get written, i'll post an example code of the image post function.

var gm = require('./gm');
var newRoute = '/some/user/url/';
var files = req.files;
gm(files.file.path).resize(1126).compress('JPEG').quality(quality)
.write(newRoute,function(err){

  //do some stuff to save changes on db

});

Now this is currently working perfectly on my local device, however on the server it wont budge, anyone have any ideas on whats going on?. the app creates folders and the folders modes are supposed to be 0777, though when i log in with ssh it seems like they might be 0755, although im not sure it's all that to do with permissions since I've got mp3 uploads working fine. it's when imagemagick and graphicsmagick come in to play that this happens. any Ideas?

Best Answer

I stumbled upon this question because I had the same issue. This is how I fixed it:

Run a simple GM command to find out the problem:

gm convert -size 120x120 randomimage.jpg -resize 120x120 thumbnail.jpg

Mine was that GM wasn't configured to support JPGs. I just removed all the GM files from usr/local and ran:

sudo yum install GraphicsMagick GraphicsMagick-devel

After this everything worked as supposed.

Related Topic