{"record":{"id":"9dc92b8bd1b691c7","repo":"Yalantis/uCrop","slug":"load-cimg-unsupported-pixel-type-s-for-file","errorCode":null,"errorMessage":"load_cimg(): Unsupported pixel type '%s' for file '%s'.","messagePattern":"load_cimg\\(\\): Unsupported pixel type '(.+?)' for file '(.+?)'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":66826,"sourceCode":"      assign(N);\n      _cimg_load_cimg_case(\"bool\",0,0,cimg_uint8);\n      _cimg_load_cimg_case(\"uint8\",\"unsigned_char\",\"uchar\",cimg_uint8);\n      _cimg_load_cimg_case(\"int8\",0,0,cimg_int8);\n      _cimg_load_cimg_case(\"char\",0,0,char);\n      _cimg_load_cimg_case(\"uint16\",\"unsigned_short\",\"ushort\",cimg_uint16);\n      _cimg_load_cimg_case(\"int16\",\"short\",0,cimg_int16);\n      _cimg_load_cimg_case(\"uint32\",\"unsigned_int\",\"uint\",cimg_uint32);\n      _cimg_load_cimg_case(\"int32\",\"int\",0,cimg_int32);\n      _cimg_load_cimg_case(\"unsigned_long\",\"ulong\",0,cimg_ulong);\n      _cimg_load_cimg_case(\"long\",0,0,cimg_long);\n      _cimg_load_cimg_case(\"uint64\",\"unsigned_int64\",0,cimg_uint64);\n      _cimg_load_cimg_case(\"int64\",0,0,cimg_int64);\n      _cimg_load_cimg_case(\"float32\",\"float\",0,cimg_float32);\n      _cimg_load_cimg_case(\"float64\",\"double\",0,cimg_float64);\n\n      if (!loaded) {\n        if (!file) cimg::fclose(nfile);\n        throw CImgIOException(_cimglist_instance\n                              \"load_cimg(): Unsupported pixel type '%s' for file '%s'.\",\n                              cimglist_instance,\n                              str_pixeltype._data,filename?filename:\"(FILE*)\");\n      }\n      if (!file) cimg::fclose(nfile);\n      return *this;\n    }\n\n    //! Load a sublist list from a (non compressed) .cimg file.\n    /**\n      \\param filename Filename to read data from.\n      \\param n0 Starting index of images to read (~0U for max).\n      \\param n1 Ending index of images to read (~0U for max).\n      \\param x0 Starting X-coordinates of image regions to read.\n      \\param y0 Starting Y-coordinates of image regions to read.\n      \\param z0 Starting Z-coordinates of image regions to read.\n      \\param c0 Starting C-coordinates of image regions to read.\n      \\param x1 Ending X-coordinates of image regions to read (~0U for max).","sourceCodeStart":66808,"sourceCodeEnd":66844,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L66808-L66844","documentation":"After trying every _cimg_load_cimg_case macro (bool, int8..uint64, float32, float64), load_cimg() throws if no pixel-type string matched the header's declared pixel type (CImg.h:66826). The .cimg header names a pixel type this CImg build does not handle.","triggerScenarios":"Loading a .cimg whose header line declares a pixel type other than the supported set (e.g. 'float16', 'bfloat16', or a misspelled type like 'uintt'), or a header line produced by an incompatible/older CImg writer.","commonSituations":"Data exported by another tool with a custom pixel-type string; typo in a hand-crafted .cimg header; reading files written by a newer CImg with types unavailable in the bundled version.","solutions":["Fix the pixel type token in the header line to one of: bool, int8/uint8/int16/uint16/int32/uint32/int64/uint64, float32 (float), float64 (double).","Re-export the data converting to a supported dtype (e.g. float32).","Check for encoding/CRLF corruption of the pixel-type field and rewrite the header cleanly."],"exampleFix":"// before (header line)\n4 float16 little_endian\n\n// after\n4 float32 little_endian","handlingStrategy":"validation","validationCode":"bool supportedPixelType(const char* path) {\n  std::FILE* f = std::fopen(path, \"rb\"); if (!f) return false;\n  char line[256] = {0};\n  bool got = std::fgets(line, sizeof line, f) != nullptr;\n  std::fclose(f);\n  char pt[64] = {0}; char en[64] = {0}; unsigned n;\n  if (!got || std::sscanf(line, \"%u %63s %63s\", &n, pt, en) < 2) return false;\n  static const char* ok[] = {\"bool\",\"int8\",\"uint8\",\"int16\",\"uint16\",\"int32\",\"uint32\",\"int64\",\"uint64\",\"float32\",\"float64\",\"float\",\"double\"};\n  for (const char* k : ok) if (!std::strcmp(pt, k)) return true;\n  return false;\n}","typeGuard":null,"tryCatchPattern":"try {\n  imgs.load_cimg(path);\n} catch (cimg_library::CImgIOException& e) {\n  if (!supportedPixelType(path)) convertCimgToFloat32(path); // rewrite header + data\n  else throw;\n}","preventionTips":["Only write .cimg headers with the documented pixel-type tokens","Convert exotic dtypes (float16/bfloat16) to float32 before export","Keep the writing and reading CImg versions aligned","Lint hand-crafted headers against the supported type list"],"tags":["cimg","cpp","pixel-type","unsupported-dtype","header-parsing"],"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"}