Yalantis/uCrop · error · CImgIOException

load_inr(): Unknown pixel type defined in file '%s'.

Error message

load_inr(): Unknown pixel type defined in file '%s'.

What it means

After reading the INR header, load_inr() dispatches on the declared pixel type (e.g. 8/16/32-bit int, float, double). If the type string in the file matches none of the supported cases, none of the _cimg_load_inr_case macros set loaded=true and the library throws CImgIOException. It means the file claims a pixel type this CImg build cannot decode.

Source

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

      std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
      int fopt[8], endian = cimg::endianness()?1:0;
      bool loaded = false;
      if (voxel_size) voxel_size[0] = voxel_size[1] = voxel_size[2] = 1;
      _load_inr_header(nfile,fopt,voxel_size);
      assign(fopt[0],fopt[1],fopt[2],fopt[3]);
      _cimg_load_inr_case(0,0,8,unsigned char);
      _cimg_load_inr_case(0,1,8,char);
      _cimg_load_inr_case(0,0,16,unsigned short);
      _cimg_load_inr_case(0,1,16,short);
      _cimg_load_inr_case(0,0,32,unsigned int);
      _cimg_load_inr_case(0,1,32,int);
      _cimg_load_inr_case(1,0,32,float);
      _cimg_load_inr_case(1,1,32,float);
      _cimg_load_inr_case(1,0,64,double);
      _cimg_load_inr_case(1,1,64,double);
      if (!loaded) {
        if (!file) cimg::fclose(nfile);
        throw CImgIOException(_cimg_instance
                              "load_inr(): Unknown pixel type defined in file '%s'.",
                              cimg_instance,
                              filename?filename:"(FILE*)");
      }
      if (!file) cimg::fclose(nfile);
      return *this;
    }

    //! Load image from a EXR file.
    /**
      \param filename Filename, as a C-string.
    **/
    CImg<T>& load_exr(const char *const filename) {
      if (!filename)
        throw CImgArgumentException(_cimg_instance
                                    "load_exr(): Specified filename is (null).",
                                    cimg_instance);
#if defined(cimg_use_openexr)

View on GitHub (pinned to f788b534b4)

Solutions

  1. Inspect the .inr header (first bytes contain the pixel type) and convert the file to a supported type (e.g. float or 8/16-bit) with another tool (inrimage tools, ImageMagick)
  2. Regenerate or re-export the file from its source application with a standard pixel type
  3. Check the file is not truncated/corrupted; re-download it
  4. Verify the file is actually INR format and not a misnamed other format

Example fix

// before
img.load_inr("weird_64bit.inr"); // throws
// after
if (system("file weird_64bit.inr") == 0) { /* confirm format */ }
system("convert weird_64bit.inr -depth 32 weird_32bit.inr"); // normalize to a supported type
img.load_inr("weird_32bit.inr");
Defensive patterns

Strategy: try-catch

Validate before calling

// Peek at the .inr header pixel type before loading
std::ifstream f(path, std::ios::binary); char head[16] = {}; f.read(head, 16);
// supported: 'unsigned char','signed char','short','int','long','float','double' variants
if (!strstr(head, "float") && !strstr(head, "unsigned char") && !strstr(head, "short") && !strstr(head, "int"))
  std::cerr << "unsupported INR pixel type, convert first\n";

Try / catch

try { img.load_inr(path); } catch (const cimg_library::CImgIOException &e) { /* unknown pixel type */ convert_with_external_tool(path); }

Prevention

When it happens

Trigger: Loading an .inr file whose header PIXTYPE is an unsupported value (e.g. unsigned 64-bit, packed/complex types, or a corrupted/garbled header); the file was opened and the header parsed, but no decoder case matched.

Common situations: Files produced by newer INR writers with types CImg does not compile support for; corrupted downloads where header bytes are garbage; hand-edited headers.

Related errors


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