javascript node.js 中的 gm 转换问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31214724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
gm conversion issue in node.js
提问by JN_newbie
I am converting an image from jpg to png, but it is giving the error. Below is the code and error.
我正在将图像从 jpg 转换为 png,但它给出了错误。下面是代码和错误。
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?
我必须 npm graphicsmagick 和 imagemagick 吗?
回答by Isidro Martínez
Probably graphicsmagick / imagemagick is not installed correctly, download GraphicsMagickor download ImageMagick, if your are using Ubuntu, these commands are useful.
可能 graphicsmagick / imagemagick 没有正确安装,下载 GraphicsMagick或下载 ImageMagick,如果你使用的是 Ubuntu,这些命令很有用。
sudo add-apt-repository ppa:dhor/myway
sudo apt-get update
sudo apt-get install graphicsmagick
sudo apt-get install imagemagick
回答by xke
Try brew install graphicsmagick
. Does that resolve the error you saw?
试试brew install graphicsmagick
。这是否解决了您看到的错误?
回答by Gh111
I had the same problem on windows! Maybe my answer will help someone!
我在 Windows 上遇到了同样的问题!也许我的回答会对某人有所帮助!
If you use gm
on windows you should download windows binaries hereand 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! ;)
如果您gm
在 Windows 上使用,您应该在此处下载 Windows 二进制文件并添加gm.exe
到您的 Windows 环境PATH
变量中。之后,您必须重新启动PC。然后安装对应的node包npm install gm
就可以了!;)
回答by JN_newbie
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.
我已经通过安装 graphicsmagick 和 imagemagick 解决了它,它在环境变量中的路径将被自动设置。然后我必须重新启动 Windows 以反映更改,现在我可以成功转换和图像。
回答by DaveIIi
When installing ImageMagick from https://imagemagick.org/script/download.php, be sure to check the option to "Install legacy utilities (convert)".
从https://imagemagick.org/script/download.php安装 ImageMagick 时,请务必选中“安装旧实用程序(转换)”选项。