Search code examples
imageformatdelegatesimagemagickdecode

ImageMagick: format supported on command line but not in C++ API?


I am successfully using ImageMagick for a wide range of formats. However, I noticed that some of the (imo) more exotic formats work just fine when I call ImageMagick on them through the command line, but they fail when I try to load the same image using the Magick++ API.

For example, the AAI image formats:

On the command line everything works fine:

$ magick identify sample.aai 
sample.aai AAI 800x600 800x600+0+0 8-bit sRGB 1.83106MiB 0.000u 0:00.002
$ magick convert sample.aai sample.jpg
$ magick identify sample.jpg 
sample.jpg JPEG 800x600 800x600+0+0 8-bit sRGB 109272B 0.000u 0:00.000

Using Magick++ however, if I do:

Magick::Image image;
image.read("/the/path/to/sample.aai");

then it fails with the error:

Magick: No decode delegate for this image format (/the/path/to/sample.aai) reported by magick/constitute.c:1534 (ReadImage)

Anybody else encounter this issue before? Anybody any suggestions as to how to solve this?

Thanks,

Irigum

PS:

$ magick --version
Version: ImageMagick 7.0.10-48 Q16 x86_64 2020-12-10 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5) 
Delegates (built-in): bzlib cairo djvu fontconfig freetype heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png raqm raw rsvg tiff webp wmf x xml zlib

My OS: Arch Linux 64-Bit


Solution

  • Imagemagick API's rarely support all of Imagemagick's operators etc. It is down to the coder of the API to decide which ones are worth including.

    Searching the web I found this page which allows you to see if your format is supported: https://www.imagemagick.org/Magick++/CoderInfo.html

    CoderInfo info("GIF"); 
    cout < info->name() << ": (" << info->description() << ") : "; 
    cout << "Readable = "; 
    if ( info->isReadable() ) 
      cout << "true"; 
    else 
      cout << "false"; 
    cout << ", "; 
    cout << "Writable = "; 
    if ( info->isWritable() ) 
      cout << "true"; 
    else 
      cout << "false"; 
    cout << ", "; 
    cout << "Multiframe = "; 
    if ( info->isMultiframe() ) 
      cout << "true"; 
    else 
      cout << "false"; 
    cout << endl;