Yalantis/uCrop · error · CImgIOException

load_pandore(): Unknown pixel datatype in file '%s'.

Error message

load_pandore(): Unknown pixel datatype in file '%s'.

What it means

The PANDORE loader dispatches on the header's declared pixel datatype, matching it against CImg's supported storage types (via sizeof checks in _cimg_load_pandore_case). If the type in the file matches none of the compiled-in alternatives, CImg throws CImgIOException. The file's header parsed fine, but its pixel encoding is not supported by this build.

Source

Thrown at ucrop/src/main/jni/CImg.h:58837

                                "encoded image dimensions (%d,%d,%d,%d).",\
                                cimg_instance,\
                                (long)fsiz,filename?filename:"(FILE*)",\
                                (int)nwidth,(int)nheight,(int)ndepth,(int)ndim); \
        assign(nwidth,nheight,ndepth,ndim); \
        const size_t siz = size(); \
        stype *buffer = new stype[siz]; \
        cimg::fread(buffer,siz,nfile); \
        if (endian) cimg::invert_endianness(buffer,siz); \
        T *ptrd = _data; \
        cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++); \
        buffer-=siz; \
        delete[] buffer

#define _cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1,stype2,stype3,ltype) { \
        if (sizeof(stype1)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1); } \
        else if (sizeof(stype2)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype2); } \
        else if (sizeof(stype3)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype3); } \
        else throw CImgIOException(_cimg_instance \
                                   "load_pandore(): Unknown pixel datatype in file '%s'.", \
                                   cimg_instance, \
                                   filename?filename:"(FILE*)"); }
      if (!file && !filename)
        throw CImgArgumentException(_cimg_instance
                                    "load_pandore(): Specified filename is (null).",
                                    cimg_instance);

      const ulongT fsiz = file?(ulongT)cimg_max_buf_size:(ulongT)cimg::fsize(filename);
      std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
      CImg<charT> header(32);
      cimg::fread(header._data,12,nfile);
      if (cimg::strncasecmp("PANDORE",header,7)) {
        if (!file) cimg::fclose(nfile);
        throw CImgIOException(_cimg_instance
                              "load_pandore(): PANDORE header not found in file '%s'.",
                              cimg_instance,
                              filename?filename:"(FILE*)");

View on GitHub (pinned to f788b534b4)

Solutions

  1. Convert the file to a common PANDORE datatype (unsigned char, int, float) using the PANDORE tools before loading
  2. Re-export from the source application with a standard type
  3. Compare the header's datatype field with CImg's supported list and pick the right loader or convert with another library
  4. Re-download the file if the header may be corrupted

Example fix

// before
img.load_pandore("exotic.pan"); // throws: unsupported datatype
// after
// convert to float datatype with PANDORE tooling, then:
img.load_pandore("exotic_float.pan");
Defensive patterns

Strategy: try-catch

Validate before calling

// Inspect the PANDORE header datatype field before loading; skip unsupported widths.
std::ifstream f(path,std::ios::binary); char h[32]={}; f.read(h,32);
// ensure datatype corresponds to 1/2/4-byte types supported by your CImg build

Try / catch

try { img.load_pandore(path); } catch (const cimg_library::CImgIOException &e) { /* unsupported datatype */ convert_with_pandore_tools(path); }

Prevention

When it happens

Trigger: Loading a .pan file whose ID_type maps to a datatype width (e.g. long double, 64-bit int) that doesn't equal any of stype1/stype2/stype3 sizes in the compiled macro expansion.

Common situations: Files written with exotic or platform-dependent PANDORE types; 64-bit platform where sizeof(long) differs from the file's expectation; corrupt header bytes.

Related errors


AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08). Data as JSON: /api/errors/518b2fe696c04e83. Report an issue: GitHub.