Yalantis/uCrop · error · CImgIOException
CImg<%s>::load_inr(): Incomplete PIXSIZE field defined in he
Error message
CImg<%s>::load_inr(): Incomplete PIXSIZE field defined in header.
What it means
Alongside TYPE, the INR header must contain a PIXSIZE field (bits per voxel: 8/16/32/64...). If the PIXSIZE line is missing or unparsable, out[6] stays -1 and this exception is thrown, separate from the TYPE checks so the user knows exactly which field is missing.
Source
Thrown at ucrop/src/main/jni/CImg.h:58688
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++); \
} \
delete[] val; \
loaded = true; \
}View on GitHub (pinned to f788b534b4)
Solutions
- Add a valid PIXSIZE line to the header (8, 16, 32, or 64 bits matching the data).
- Re-export the file with a standard INR writer.
- Validate generated headers contain all of XDIM/YDIM/ZDIM/VDIM/TYPE/PIXSIZE/Endianity before finalizing.
- Check that PIXSIZE matches the actual buffer size to avoid a downstream short read.
- Catch CImgIOException and instruct users which header field to add.
Example fix
# before (header, PIXSIZE missing) TYPE=unsigned fixed # after TYPE=unsigned fixed PIXSIZE=16
Defensive patterns
Strategy: validation
Validate before calling
bool inrPixsizeValid(const std::string& headerText) {
for (int bits : {8, 16, 32, 64}) {
if (headerText.find("PIXSIZE=" + std::to_string(bits)) != std::string::npos) return true;
}
return false;
} Type guard
bool hasValidPixsize(int pixsize) { return pixsize == 8 || pixsize == 16 || pixsize == 32 || pixsize == 64; } Try / catch
try { img.load_inr(path); }
catch (CImgIOException& e) { fprintf(stderr, "PIXSIZE missing/invalid in INR header\n"); } Prevention
- Always emit a numeric PIXSIZE (8/16/32/64) in INR headers.
- Match PIXSIZE to the actual voxel buffer size.
- Spell the field exactly 'PIXSIZE=' with an integer value.
- Round-trip test generated files by loading them immediately.
When it happens
Trigger: Header lacks a 'PIXSIZE=NN' line or it doesn't match the fscanf/sscanf patterns used; raised from load_inr()/load() on an .inr file whose out[4]/out[5] passed but out[6]<0.
Common situations: Custom INR writers omitting PIXSIZE; header edited down to just XDIM/YDIM/ZDIM/VDIM/TYPE; corrupted token (e.g. 'PIXSIZE = thirty-two') that fails numeric parsing.
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 pixel type defined in heade
- CImg<%s>::load_inr(): Big/Little Endian coding type undefine
- CImg<%s>::load_inr(): INRIMAGE-4 header not found.
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/d7b287dde844c70b.
Report an issue: GitHub.