12

I am converting an image from jpg to png, but it is giving the error. Below is the code and error.

gm('E:/image1.jpg').write('E:/image2.png', function(err){
        if (err){
            console.log(err);
        } else{console.log('image converted.')}
    })

The error is:

[Error: Could not execute GraphicsMagick/ImageMagick: gm "convert" "E:/image1.jpg" "E:/image2.png" this most likely means the gm/convert binaries can't be found]

Do I have to npm graphicsmagick and imagemagick?

08Dc91wk
  • 4,254
  • 8
  • 34
  • 67
JN_newbie
  • 5,492
  • 14
  • 59
  • 97

9 Answers9

22

Probably graphicsmagick / imagemagick is not installed correctly, download GraphicsMagick or download ImageMagick, if your are using Ubuntu, these commands are useful.

sudo add-apt-repository ppa:dhor/myway
sudo apt-get update
sudo apt-get install graphicsmagick
sudo apt-get install imagemagick
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Isidro Martínez
  • 816
  • 7
  • 15
  • 1
    I got an error because I thought graphicsmagic will automatically download imagemagick also, but it's not. After seen your answer I installed imagemagick and issue solved, you rock buddy. – Yogesh Patil Aug 29 '18 at 08:01
  • You sir, are a genius, almost pulled all the hair in my afro coz of that error – David Kabii Oct 03 '19 at 10:20
10

I had the same problem on windows! Maybe my answer will help someone!

If you use gm on windows you should download windows binaries here and add gm.exe to your windows environment PATH variable. After that you have to restart your PC. Then install corresponding node package with npm install gm and it will work! ;)

Gh111
  • 1,362
  • 18
  • 19
8

Try brew install graphicsmagick. Does that resolve the error you saw?

xke
  • 1,073
  • 12
  • 13
  • 2
    I have tried installing graphicsmagick and its path to the enviroment variable is also set while installing. but still not working. – JN_newbie Jul 04 '15 at 05:20
5

I have got it resolved by installing graphicsmagick and imagemagick and its path in environment variable will be automatically set out. Then I have to restart the windows to reflect the changes and now I can successfully converts and image.

JN_newbie
  • 5,492
  • 14
  • 59
  • 97
1

Just try with below command and it will solve your problem

  • sudo apt install graphicsmagick
Nilesh Patil
  • 41
  • 1
  • 2
0

When installing ImageMagick from https://imagemagick.org/script/download.php, be sure to check the option to "Install legacy utilities (convert)".

DaveIIi
  • 101
  • 1
  • 1
0

Opensuse

If you are developing on OpenSuse OS this issue can arise as well. To solve, you need to install the ImageMagick and GraphicsMagick packages:

sudo zypper install ImageMagick GraphicsMagick
kalwalt
  • 460
  • 4
  • 12
0

There few steps to solve this error.

  1. Confirm the GraphicsMagick is installed in your user in the terminal.

  2. $ gm

  3. $ sudo gm //Command Line Screenshot

  4. Both "gm" and "sudo gm" commands should return the most of the time server running in the sudo user and we might have installed this in normal user so that Sudo user don't know the about installed package configure in the normal user. In short, make sure code running in sudo user then same mode GraphicsMagick should be available.

If did not got the above and got something like "command not found in the terminal" then use this link. https://www.tecmint.com/graphicsmagick-image-processing-cli-tool-for-linux/

also check the this link contains only command package might not available to download so https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/ change the version in the download link of the wget and follow the steps in above link.

0

GraphicsMagick Windows Installation

step 1:

choco install graphicsmagick

Follow this doc to install Chocolatey on windows :)

step 2:

go to graphicsmagick installation location.

Ex: C:\Program Files\GraphicsMagick-1.3.36-Q8

step 3:

add gm.exe location to your windows environment PATH variable

Ex: C:\Program Files\GraphicsMagick-1.3.36-Q8

setp 4:

open a new terminal (command prompt/ powershell)

run gm.exe

if you get 'gm.exe unable to start correctly' error, install the VS2008 package from this page

step 5:

test the installation

Select "Command Prompt" from the Windows Start menu. Within the window type

gm convert logo: logo.miff

gm convert logo.miff win:

and the GraphicsMagick logo should be displayed in a window.

Lojith Vinsuka
  • 906
  • 1
  • 10
  • 8