C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c – CImg错误:’gm.exe’未被识别为内部或外部命令,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我是c编程新手,今天我尝试使用CImg保存图像.
CImg是C模板图像处理库.

我写的基本代码是(请原谅任何语法错误,作为我的代码的复制部分):

#include "CImg.h"// Include CImg library header.
#include <iostream>

using namespace cimg_library;
using namespace std;

const int screen_size = 800;

//-------------------------------------------------------------------------------
//  Main procedure
//-------------------------------------------------------------------------------
int main()
{

CImg<unsigned char> img(screen_size,screen_size,1,3,20);
CImgDisplay disp(img,"CImg Tutorial");   
//Some drawing using img.draw_circle( 10,10,60,RED);
img.save("result.jpg"); // save the image    
return 0;   
}

我无法运行我的程序,因为它说:

Invalid Parameter - 100%
'gm.exe' is not recognized as an internal or external command,operable program or batch file.

This application has requested the Runtime to terminate it in an unusual way.
please contact the application's support team for more information.

[CImg] *** CImgIOException *** [instance(800,800,02150020,non-shared)] CImg<unsigned char>::save_other() : Failed to save file 'result.jpg'. Format is not natively supported,and no external commands succeeded.
terminate called after throwing an instance of 'cimg_library::CImgIOException'
  what():  [instance(800,and no external commands succeeded.

然我可以看到图像,但我无法保存.
谷歌搜索后,我发现人们说要安装ImageMagick,我已经安装了它但没有帮助.
一些论坛说要针对libjpeg,libpng,libmagick进行编译.但我不知道如何编译这些库.
我正在使用Eclipse CDT插件来编写C项目.
请帮我 .

解决方法

我有同样的错误,并安装Graphicsmagick(不是ImageMagick)帮助了我.

我已经从ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/windows/下载并安装了Graphicsmagick-1.3.26-Q8-win64-dll.exe.如果需要,您可以选择另一个

重要提示:在@R_199_9382@,请不要删除“更新可执行搜索路径”复选框,它会更新环境变量%PATH%,从而可以从任何地方使用gm.exe.

在我的情况下,还需要安装Ghostscript – 强烈建议由Graphicsmagick安装.有一个链接到x64 Ghostscript:https://sourceforge.net/projects/ghostscript/files/GPL%20Ghostscript/9.09/gs909w64.exe/download(我把它放在这里,因为来自GraphicMagick网站的链接只引导你到32位).

在那之后,它对我来说很好.

大佬总结

以上是大佬教程为你收集整理的c – CImg错误:’gm.exe’未被识别为内部或外部命令,全部内容,希望文章能够帮你解决c – CImg错误:’gm.exe’未被识别为内部或外部命令,所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。