Search code examples
node.jsamazon-ec2imagemagickgraphicsmagick

spawn ENOENT error with NodeJS while using gm Module in node JS


I am using gm node module on AWS EC2 Instance with a Linux OS. My Aim to crop the image provided by the url from the S3 bucket.I am doing http request to the image url from the S3 bucket to get the buffer and passing the buffer value to the gm module. My Code is as follows:

  gm(buffer).crop(width, height, x, y).toBuffer(imageExtension, function (err, buffer) {
            if (err) {
               //error Handling
            } else {
              //Some Logic
            }
    });

When I pass the buffer to the gm crop module , I get spawn ENOENT error.

events.js:85
throw err; // Unhandled 'error' event
      ^
Error: spawn convert ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickDomainCallback (node.js:381:11)

I referred to following links on stack overflow for reference but couldn't fix the error.

  1. Error: spawn ENOENT while using GM in node
  2. Node.js: Error: spawn ENOENT while using GM module
  3. spawn ENOENT error with NodeJS
  4. nodejs - Error: spawn ENOENT while adjusting image size using module gm

Can Somebody help me with this issue?


Solution

  • To Resolve this issue I referred to the following link on server fault

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

    I Ran the command given below on the Amazon EC2 instance terminal and the dependencies for the linux architecture was installed on the server and gm node module started working properly.

    sudo yum install GraphicsMagick GraphicsMagick-devel ImageMagick