{"record":{"id":"7ca8d19ead8299ff","repo":"Yalantis/uCrop","slug":"save-cimg-unsupported-data-type-s-for-file","errorCode":null,"errorMessage":"save_cimg(): Unsupported data type '%s' for file '%s'.","messagePattern":"save_cimg\\(\\): Unsupported data type '(.+?)' for file '(.+?)'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":68336,"sourceCode":"      if (!cimg::strncasecmp(\"little\",str_endian,6)) endian = false;\n      else if (!cimg::strncasecmp(\"big\",str_endian,3)) endian = true;\n      const unsigned int lmax = std::min(N,n0 + _width);\n      _cimg_save_cimg_case(\"bool\",0,0,cimg_uint8);\n      _cimg_save_cimg_case(\"uint8\",\"unsigned_char\",\"uchar\",cimg_uint8);\n      _cimg_save_cimg_case(\"int8\",0,0,cimg_int8);\n      _cimg_save_cimg_case(\"char\",0,0,char);\n      _cimg_save_cimg_case(\"uint16\",\"unsigned_short\",\"ushort\",cimg_uint16);\n      _cimg_save_cimg_case(\"int16\",\"short\",0,cimg_int16);\n      _cimg_save_cimg_case(\"uint32\",\"unsigned_int\",\"uint\",cimg_uint32);\n      _cimg_save_cimg_case(\"int32\",\"int\",0,cimg_int32);\n      _cimg_save_cimg_case(\"uint64\",\"unsigned_int64\",0,cimg_uint64);\n      _cimg_save_cimg_case(\"int64\",0,0,cimg_int64);\n      _cimg_save_cimg_case(\"float\",\"float32\",0,cimg_float32);\n      _cimg_save_cimg_case(\"float64\",\"double\",0,cimg_float64);\n\n      if (!saved) {\n        if (!file) cimg::fclose(nfile);\n        throw CImgIOException(_cimglist_instance\n                              \"save_cimg(): Unsupported data type '%s' for file '%s'.\",\n                              cimglist_instance,\n                              filename?filename:\"(FILE*)\",str_pixeltype._data);\n      }\n      if (!file) cimg::fclose(nfile);\n      return *this;\n    }\n\n    //! Insert the image instance into into an existing .cimg file, at specified coordinates.\n    /**\n      \\param filename Filename to write data to.\n      \\param n0 Starting index of images to write.\n      \\param x0 Starting X-coordinates of image regions to write.\n      \\param y0 Starting Y-coordinates of image regions to write.\n      \\param z0 Starting Z-coordinates of image regions to write.\n      \\param c0 Starting C-coordinates of image regions to write.\n    **/\n    const CImgList<T>& save_cimg(const char *const filename,","sourceCodeStart":68318,"sourceCodeEnd":68354,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L68318-L68354","documentation":"save_cimg writes a pixel-type tag in the CImg header and only knows how to serialize the C++ types it was instantiated/matched for (bool, char..double, int64, float32/64, etc., via the _cimg_save_cimg_case macros). If the list's pixel type T has no matching case (saved stays false), it throws CImgIOException naming the unrecognized type string.","triggerScenarios":"Using a CImgList of an exotic pixel type T that none of the save_cimg cases cover, then calling save_cimg.","commonSituations":"Custom typedefs or exotic integer widths as the pixel type; template code instantiating CImgList with a user type; porting code to a platform where the type string doesn't match any known case.","solutions":["Convert the list to a supported pixel type first, e.g. list.get_shared() copies: CImgList<float> out(list); then out.save_cimg(filename).","Use one of the standard types (unsigned char, float, double, int, ...) as your image pixel type.","If you must keep the custom type, write the data manually (serialize dimensions + raw buffer) instead of save_cimg."],"exampleFix":"// before\nCImgList<MyType> list; // unsupported pixel type\nlist.save_cimg(\"out.cimg\");\n// after\nCImgList<float> out(list); // convert to supported type\nout.save_cimg(\"out.cimg\");","handlingStrategy":"type-guard","validationCode":"// convert unsupported pixel types beforehand\nCImgList<float> out(list);\nout.save_cimg(path);","typeGuard":"template<typename T> struct cimg_saveable : std::integral_constant<bool, std::is_arithmetic<T>::value> {};","tryCatchPattern":"try { list.save_cimg(path); } catch (CImgIOException &e) { CImgList<float> out(list); out.save_cimg(path); }","preventionTips":["Use standard pixel types (unsigned char, float, double, int...) for images","Convert exotic types with CImgList<float> out(list) before saving"],"tags":["unsupported-type","dtype","image-io"],"backgroundTag":"unsupported-dtype","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}