{"record":{"id":"81ec698c637edb29","repo":"Yalantis/uCrop","slug":"cimg-s-load-inr-invalid-pixel-type-s-defi","errorCode":null,"errorMessage":"CImg<%s>::load_inr(): Invalid pixel type '%s' defined in header.","messagePattern":"CImg<(.+?)>::load_inr\\(\\): Invalid pixel type '(.+?)' defined in header\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":58675,"sourceCode":"        cimg_sscanf(item,\" PIXSIZE%*[^0-9]%d\",out + 6);\n        if (voxel_size) {\n          cimg_sscanf(item,\" VX%*[^0-9.+-]%f\",voxel_size);\n          cimg_sscanf(item,\" VY%*[^0-9.+-]%f\",voxel_size + 1);\n          cimg_sscanf(item,\" VZ%*[^0-9.+-]%f\",voxel_size + 2);\n        }\n        if (cimg_sscanf(item,\" CPU%*[ =]%s\",tmp1._data)) out[7] = cimg::strncasecmp(tmp1,\"sun\",3)?0:1;\n        switch (cimg_sscanf(item,\" TYPE%*[ =]%s %s\",tmp1._data,tmp2._data)) {\n        case 0 : break;\n        case 2 :\n          out[5] = cimg::strncasecmp(tmp1,\"unsigned\",8)?1:0;\n          std::strncpy(tmp1,tmp2,tmp1._width - 1); // Fallthrough\n        case 1 :\n          if (!cimg::strncasecmp(tmp1,\"int\",3) || !cimg::strncasecmp(tmp1,\"fixed\",5))  out[4] = 0;\n          if (!cimg::strncasecmp(tmp1,\"float\",5) || !cimg::strncasecmp(tmp1,\"double\",6)) out[4] = 1;\n          if (!cimg::strncasecmp(tmp1,\"packed\",6)) out[4] = 2;\n          if (out[4]>=0) break; // Fallthrough\n        default :\n          throw CImgIOException(\"CImg<%s>::load_inr(): Invalid pixel type '%s' defined in header.\",\n                                pixel_type(),\n                                tmp2._data);\n        }\n      }\n      if (out[0]<0 || out[1]<0 || out[2]<0 || out[3]<0)\n        throw CImgIOException(\"CImg<%s>::load_inr(): Invalid dimensions (%d,%d,%d,%d) defined in header.\",\n                              pixel_type(),\n                              out[0],out[1],out[2],out[3]);\n      if (out[4]<0 || out[5]<0)\n        throw CImgIOException(\"CImg<%s>::load_inr(): Incomplete pixel type defined in header.\",\n                              pixel_type());\n      if (out[6]<0)\n        throw CImgIOException(\"CImg<%s>::load_inr(): Incomplete PIXSIZE field defined in header.\",\n                              pixel_type());\n      if (out[7]<0)\n        throw CImgIOException(\"CImg<%s>::load_inr(): Big/Little Endian coding type undefined in header.\",\n                              pixel_type());\n    }","sourceCodeStart":58657,"sourceCodeEnd":58693,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L58657-L58693","documentation":"The INR header's TYPE field (e.g. 'int', 'fixed', 'float', 'double', 'packed' combined with PIXSIZE) must map to a supported pixel class; out[4] records it (0=integer,1=float,2=packed). If TYPE/PIXSIZE combination is unrecognized, out[4] stays -1 and this exception is thrown, listing the raw TYPE/PIXSIZE string from the header.","triggerScenarios":"Header contains a TYPE value the parser doesn't recognize (e.g. TYPE=unsigned fixed, TYPE=surfel, misspelled 'flaot') or a valid TYPE reached the default branch because no known keyword matched; raised from load_inr()/load() on .inr files.","commonSituations":"Files produced by non-standard INR writers with exotic TYPE strings (signed, rgb packed variants); manual header edits; locale/whitespace corruption shifting the parsed token into tmp2.","solutions":["Open the header (text section at the end/after '#INRIMAGE-4#{') and set TYPE to a supported keyword: int, fixed, float, double, or packed.","Ensure PIXSIZE (out[5]/bits) pairs correctly with TYPE (e.g. TYPE=float with PIXSIZE=32); an odd PIXSIZE can leave the case unmatched.","Re-export the volume with standard settings (e.g. TYPE=float, PIXSIZE=32, or TYPE=unsigned fixed PIXSIZE=8/16).","Update the bundled CImg.h — newer versions accept more TYPE/PIXSIZE combos.","Catch CImgIOException, parse the header yourself, and convert the data to a supported type."],"exampleFix":"# before (header)\nTYPE=flaot\nPIXSIZE=32\n# after\nTYPE=float\nPIXSIZE=32","handlingStrategy":"validation","validationCode":"bool inrTypeSupported(const std::string& headerText) {\n  static const char* ok[] = {\"int\", \"fixed\", \"float\", \"double\", \"packed\"};\n  for (const char* k : ok) if (headerText.find(std::string(\"TYPE=\") + k) != std::string::npos) return true;\n  return false;\n}","typeGuard":"bool isKnownInrType(const std::string& t) {\n  return t == \"int\" || t == \"fixed\" || t == \"float\" || t == \"double\" || t == \"packed\";\n}","tryCatchPattern":"try { img.load_inr(path); }\ncatch (CImgIOException& e) { fprintf(stderr, \"Unsupported TYPE in INR header — fix header or re-export\\n\"); }","preventionTips":["Only emit TYPE values from the supported keyword set when writing INR files.","Keep TYPE/PIXSIZE pairs standard (e.g. float+32, unsigned fixed+8/16).","Lint generated INR headers against a field checklist.","Update CImg.h for newer TYPE support."],"tags":["cimg","pixel-type","inrimage","header"],"backgroundTag":"invalid-enum-value","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"}