CImg failed to recognize the format “jpeg”

半城伤御伤魂 提交于 2020-01-05 20:31:32

问题


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.

My code is :

#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;
}

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!


回答1:


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

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

To install ImageMagick, run

brew install imagemagick

To uninstall ImageMagick, run

brew rm imagemagick

To install Cimg, run

brew install cimg

To find ffmpeg, or GNU Parallel, just do

brew search ffmpeg
brew search parallel

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

brew doctor

and it will tell you about any problems or inconsistencies.



来源:https://stackoverflow.com/questions/30458645/cimg-failed-to-recognize-the-format-jpeg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!