CImg无法识别格式“jpeg” [英] CImg failed to recognize the format "jpeg"

查看:700
本文介绍了CImg无法识别格式“jpeg”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了加载图像,我在我的mac(OSX 10.10)中安装了CImg库。幸运的是我设法显示了bmp图片,但我无法加载并显示其他格式,如png或jpg。
然后我安装了从 http://cactuslab.com/imagemagick/ 下载的ImageMagic然后运行程序。错误仍然存​​在。

To load image, I installed the CImg library in my mac(OSX 10.10). Luckily I managed to display the bmp picture, but I failed to load and display other formats like png or jpg. Then I installed the ImageMagic which is downloaded from http://cactuslab.com/imagemagick/ and then run the program. The errors are still there.

我的代码是:

#include "CImg.h"
#include <stdlib.h>
#define cimg_use_magick
using namespace cimg_library;

int main() {
CImg<unsigned char> image("lena.jpg");

image.display();

return 0;
}

程序可以在我的Xcode中成功构建,但它报告的错误是未能识别格式
我只是不知道如何修复它。谢谢你的帮助!

The program can be built successfully in my Xcode but it reported the error that is "failed to recognize the format" I just don't know how to fix it. thanks for your help!

推荐答案

我猜你的ImageMagick安装没有必要的库来读取JPEG文件。 ImageMagick将各种图像格式的处理程序称为 DELEGATES ,因此请尝试使用此命令查看ImageMagick安装可以处理的格式:

I am guessing your ImageMagick installation does not have the necessary libraries for reading JPEG files. ImageMagick refers to the handlers for the various image formats as DELEGATES, so try this command to see what formats your ImageMagick installation can cope with:

identify -list configure | grep DELEGATES
DELEGATES      bzlib mpeg freetype jng jpeg lzma png tiff xml zlib

就我个人而言,我从不使用 CactusLabs 安装取得了成功。我使用 homebrew 。您从此处复制单行安装脚本,然后您可以使用<$ c管理Mac上的所有程序包$ c> brew 命令。例如,要查找ImageMagick包的名称,只需执行

Personally, I never had any success with the CactusLabs installation. I use homebrew. You copy the one-liner installation script from here, and then you can simply manage all packages on your Mac with the brew command. For example, to find the name of the ImageMagick package, just do

brew search imagemagick

要安装ImageMagick,请运行

To install ImageMagick, run

brew install imagemagick

要卸载ImageMagick,请运行

To uninstall ImageMagick, run

brew rm imagemagick

要安装Cimg,请运行

To install Cimg, run

brew install cimg

要查找 ffmpeg GNU Parallel ,只需执行

brew search ffmpeg
brew search parallel

要解决 homebrew 的任何问题,只需致电医生:

To sort out any problems with homebrew, just call the Doctor:

brew doctor

它会告诉你任何问题或不一致。

and it will tell you about any problems or inconsistencies.

这篇关于CImg无法识别格式“jpeg”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆