问题
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?
回答1:
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
回答2:
Try brew install graphicsmagick
. Does that resolve the error you saw?
回答3:
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! ;)
回答4:
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.
回答5:
When installing ImageMagick from https://imagemagick.org/script/download.php, be sure to check the option to "Install legacy utilities (convert)".
来源:https://stackoverflow.com/questions/31214724/gm-conversion-issue-in-node-js