{"record":{"id":"2143b66e1c9a772f","repo":"Yalantis/uCrop","slug":"load-inr-unknown-pixel-type-defined-in-file-s","errorCode":null,"errorMessage":"load_inr(): Unknown pixel type defined in file '%s'.","messagePattern":"load_inr\\(\\): Unknown pixel type defined in file '(.+?)'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":58731,"sourceCode":"      std::FILE *const nfile = file?file:cimg::fopen(filename,\"rb\");\n      int fopt[8], endian = cimg::endianness()?1:0;\n      bool loaded = false;\n      if (voxel_size) voxel_size[0] = voxel_size[1] = voxel_size[2] = 1;\n      _load_inr_header(nfile,fopt,voxel_size);\n      assign(fopt[0],fopt[1],fopt[2],fopt[3]);\n      _cimg_load_inr_case(0,0,8,unsigned char);\n      _cimg_load_inr_case(0,1,8,char);\n      _cimg_load_inr_case(0,0,16,unsigned short);\n      _cimg_load_inr_case(0,1,16,short);\n      _cimg_load_inr_case(0,0,32,unsigned int);\n      _cimg_load_inr_case(0,1,32,int);\n      _cimg_load_inr_case(1,0,32,float);\n      _cimg_load_inr_case(1,1,32,float);\n      _cimg_load_inr_case(1,0,64,double);\n      _cimg_load_inr_case(1,1,64,double);\n      if (!loaded) {\n        if (!file) cimg::fclose(nfile);\n        throw CImgIOException(_cimg_instance\n                              \"load_inr(): Unknown pixel type defined in file '%s'.\",\n                              cimg_instance,\n                              filename?filename:\"(FILE*)\");\n      }\n      if (!file) cimg::fclose(nfile);\n      return *this;\n    }\n\n    //! Load image from a EXR file.\n    /**\n      \\param filename Filename, as a C-string.\n    **/\n    CImg<T>& load_exr(const char *const filename) {\n      if (!filename)\n        throw CImgArgumentException(_cimg_instance\n                                    \"load_exr(): Specified filename is (null).\",\n                                    cimg_instance);\n#if defined(cimg_use_openexr)","sourceCodeStart":58713,"sourceCodeEnd":58749,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L58713-L58749","documentation":"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.","triggerScenarios":"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.","commonSituations":"Files produced by newer INR writers with types CImg does not compile support for; corrupted downloads where header bytes are garbage; hand-edited headers.","solutions":["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)","Regenerate or re-export the file from its source application with a standard pixel type","Check the file is not truncated/corrupted; re-download it","Verify the file is actually INR format and not a misnamed other format"],"exampleFix":"// before\nimg.load_inr(\"weird_64bit.inr\"); // throws\n// after\nif (system(\"file weird_64bit.inr\") == 0) { /* confirm format */ }\nsystem(\"convert weird_64bit.inr -depth 32 weird_32bit.inr\"); // normalize to a supported type\nimg.load_inr(\"weird_32bit.inr\");","handlingStrategy":"try-catch","validationCode":"// Peek at the .inr header pixel type before loading\nstd::ifstream f(path, std::ios::binary); char head[16] = {}; f.read(head, 16);\n// supported: 'unsigned char','signed char','short','int','long','float','double' variants\nif (!strstr(head, \"float\") && !strstr(head, \"unsigned char\") && !strstr(head, \"short\") && !strstr(head, \"int\"))\n  std::cerr << \"unsupported INR pixel type, convert first\\n\";","typeGuard":null,"tryCatchPattern":"try { img.load_inr(path); } catch (const cimg_library::CImgIOException &e) { /* unknown pixel type */ convert_with_external_tool(path); }","preventionTips":["Keep source files in standard 8/16-bit or float encodings","Validate header bytes before decoding unfamiliar files","Re-download files whose headers fail sanity checks"],"tags":["cimg","image-loading","inr","unsupported-dtype"],"backgroundTag":"unsupported-dtype","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}