gpt4 book ai didi

c++ - CImg 错误 : 'gm.exe' is not recognized as an internal or external command,

转载 作者:太空狗 更新时间:2023-10-29 20:04:36 31 4
gpt4 key购买 nike

我是 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,1,3,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,800,1,3,02150020,non-shared)] CImg<unsigned char>::save_other() : Failed to save file 'result.jpg'. Format is not natively supported, 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 .如果需要,您可以选择另一个:

Note that the QuantumDepth=8 version (Q8) which provides industry standard 24/32 bit pixels consumes half the memory and about 30% less CPU than the QuantumDepth=16 version (Q16) which provides 48/64 bit pixels for high-resolution color. A Q8 version is fine for processing typical photos intended for viewing on a computer screen. If you are dealing with film, scientific, or medical images, use ICC color profiles, or deal with images that have limited contrast, then the Q16 version is recommended.

重要:在安装过程中,不要删除复选框“更新可执行文件搜索路径”,这会更新环境变量 %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' is not recognized as an internal or external command,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18733695/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com