Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Node.js ImageMagick & GM both cause error 127 when trying to load a valid image

Node.js ImageMagick & GM both cause error 127 when trying to load a valid image

Problem

I have a node app which accepts an uploaded image (using formidable) and stores it into an Amazon S3 bucket. Before it is saved to S3, I want to get the image's width, height, etc. for future consideration. I found this question which helped: Opening images on NodeJS and finding out width/height

However, when I try to open the image with Imagemagick (or gm, for that matter, I've tried both) I get Error 127. Specifically, imagemagick reports:

{"timedOut":false,"killed":false,"code":127,"signal":null}

I know the file exists (because it is properly uploaded to the S3 bucket), and I can manipulate it (eg, rename) via fs, but I cannot find any documentation on error code 127 to determine why IM fails. Thinking that perhaps there was something odd about the file uploaded to formidable causing it to not be read properly, I tried using imagemagick to load a simple "test.jpg" image in the same folder:

    im.identify('test.jpg', function(err, features){
        if(!err) 
        {
            // my image processing code
        }
        else
        {
            // my err handling code; spits out the error above
        }
    });

Unfortunately, this fails in the exact same manner, even though I'm sure test.jpg is a good and properly formatted image.

So, can anybody help me understand what error 127 is and why ImageMagick would throw it when fs is able to read the file just fine...?

Problem courtesy of: Zane Claes

Solution

Derp. I didn't have ImageMagick itself installed. I assumed that the NPM installation was all that was required; did not realize there were additional dependencies, and the error message was a bit cryptic ;)

Solution courtesy of: Zane Claes

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Node.js ImageMagick & GM both cause error 127 when trying to load a valid image

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×