Yalantis/uCrop · error · CImgIOException
CImg<%s>::load_inr(): Incomplete pixel type defined in heade
Error message
CImg<%s>::load_inr(): Incomplete pixel type defined in header.
What it means
The INR header must fully specify the pixel type via both TYPE (out[4]) and PIXSIZE (out[5]). If either keyword was absent/unparsed so that out[4] or out[5] remains the sentinel -1, _load_inr_header() throws this exception — the pixel encoding is incomplete, not merely invalid.
Source
Thrown at ucrop/src/main/jni/CImg.h:58685
out[5] = cimg::strncasecmp(tmp1,"unsigned",8)?1:0;
std::strncpy(tmp1,tmp2,tmp1._width - 1); // Fallthrough
case 1 :
if (!cimg::strncasecmp(tmp1,"int",3) || !cimg::strncasecmp(tmp1,"fixed",5)) out[4] = 0;
if (!cimg::strncasecmp(tmp1,"float",5) || !cimg::strncasecmp(tmp1,"double",6)) out[4] = 1;
if (!cimg::strncasecmp(tmp1,"packed",6)) out[4] = 2;
if (out[4]>=0) break; // Fallthrough
default :
throw CImgIOException("CImg<%s>::load_inr(): Invalid pixel type '%s' defined in header.",
pixel_type(),
tmp2._data);
}
}
if (out[0]<0 || out[1]<0 || out[2]<0 || out[3]<0)
throw CImgIOException("CImg<%s>::load_inr(): Invalid dimensions (%d,%d,%d,%d) defined in header.",
pixel_type(),
out[0],out[1],out[2],out[3]);
if (out[4]<0 || out[5]<0)
throw CImgIOException("CImg<%s>::load_inr(): Incomplete pixel type defined in header.",
pixel_type());
if (out[6]<0)
throw CImgIOException("CImg<%s>::load_inr(): Incomplete PIXSIZE field defined in header.",
pixel_type());
if (out[7]<0)
throw CImgIOException("CImg<%s>::load_inr(): Big/Little Endian coding type undefined in header.",
pixel_type());
}
CImg<T>& _load_inr(std::FILE *const file, const char *const filename, float *const voxel_size) {
#define _cimg_load_inr_case(Tf,sign,pixsize,Ts) \
if (!loaded && fopt[6]==pixsize && fopt[4]==Tf && fopt[5]==sign) { \
Ts *xval, *const val = new Ts[(size_t)fopt[0]*fopt[3]]; \
cimg_forYZ(*this,y,z) { \
cimg::fread(val,fopt[0]*fopt[3],nfile); \
if (fopt[7]!=endian) cimg::invert_endianness(val,fopt[0]*fopt[3]); \
xval = val; cimg_forX(*this,x) cimg_forC(*this,c) (*this)(x,y,z,c) = (T)*(xval++); \
} \View on GitHub (pinned to f788b534b4)
Solutions
- Add/repair both TYPE and PIXSIZE lines in the header, e.g. TYPE=float and PIXSIZE=32.
- Re-export with a standard INR writer to regenerate a complete header.
- When generating headers, assert out[4]>=0 && out[5]>=0 before writing '##}'.
- Inspect the text block after the magic token — ensure the file wasn't truncated before '##}'.
- Catch CImgIOException and distinguish 'incomplete' vs 'invalid pixel type' to guide repair.
Example fix
# before (header, TYPE line missing) PIXSIZE=32 # after TYPE=float PIXSIZE=32
Defensive patterns
Strategy: validation
Validate before calling
bool inrPixelSpecComplete(const std::string& headerText) {
return headerText.find("TYPE=") != std::string::npos
&& headerText.find("PIXSIZE=") != std::string::npos;
} Type guard
bool pixelTypeSpecified(int typeCode, int pixCode) { return typeCode >= 0 && pixCode >= 0; } Try / catch
try { img.load_inr(path); }
catch (CImgIOException& e) { fprintf(stderr, "Incomplete pixel type — add TYPE and PIXSIZE lines\n"); } Prevention
- Include both TYPE and PIXSIZE in every generated INR header.
- Never hand-trim header fields; edit values, not lines.
- Verify the file retains its full trailing text block (through '##}').
- Validate headers with a checklist at export time.
When it happens
Trigger: Header omits the TYPE line entirely (out[4]==-1) or omits PIXSIZE (out[5]==-1); the TYPE line exists but no keyword matched AND the case-1 fallthrough left out[4] negative; raised from load_inr()/load() on .inr files.
Common situations: Hand-trimmed headers missing fields; writers that emit only PIXSIZE assuming a default TYPE; truncation of the trailing text block of the INR file where these lines live.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- CImg<%s>::load_inr(): Invalid pixel type '%s' defined in hea
- CImg<%s>::load_inr(): Invalid dimensions (%d,%d,%d,%d) defin
- CImg<%s>::load_inr(): Incomplete PIXSIZE field defined in he
- CImg<%s>::load_inr(): Big/Little Endian coding type undefine
- assign(): Invalid assignment request of shared instance from
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/13f0eb296ad4f140.
Report an issue: GitHub.