Yalantis/uCrop · error · CImgIOException
load_parrec(): Unsupported
Error message
load_parrec(): Unsupported %d-bits pixel type for file '%s'.
What it means
load_parrec() reads the pixel size in bits ('pixsize') from the PAR file header and supports only the bit depths Philips PAR/REC defines. When the header declares an unsupported bit depth, CImg closes both open files (PAR and REC) and throws CImgIOException.
Solutions
- Check the 'Pixel size' / bits-per-pixel field in the PAR header; re-export the scan with a standard bit depth (8/16/32-bit)
- Upgrade the CImg library version - newer versions support more PAR/REC bit depths
- Convert the REC data externally (e.g. with dcm2nii or Philips tools) to a standard format (NIfTI/DICOM) and load that instead
- Verify the PAR file is complete and uncorrupted
Example fix
// before
imgs.load_parrec("scan.par"); // header says 20 bits
// after
// re-export scan with standard 16-bit reconstruction, then:
imgs.load_parrec("scan_16bit.par"); Defensive patterns
Strategy: try-catch
Validate before calling
int bits = parseParPixelBits(path); // read bits/pixel from PAR header
if (bits != 8 && bits != 16 && bits != 24 && bits != 32) { /* re-export or convert first */ } Try / catch
try { imgs.load_parrec(parPath); }
catch (CImgIOException& e) { fprintf(stderr, "PAR/REC unsupported data: %s\n", e.what()); /* convert to NIfTI/DICOM */ } Prevention
- Keep scanner exports at standard bit depths
- Pin a known-good CImg version compatible with your Philips release
- Keep the original DICOM export as fallback
When it happens
Trigger: load_parrec() on a PAR file whose header records a pixel bit size not matching any handled case (the standard 8/12/16/24/32-bit cases); a corrupted or non-standard PAR header; a PAR file from an unsupported scanner protocol.
Common situations: Files exported with non-standard reconstruction settings; hand-edited or truncated PAR headers; third-party tools writing PAR-like headers with unusual bit depths; scanner firmware producing newer/older formats than the bundled CImg supports.
Related errors
- load_parrec(): Failed to recognize valid PAR-REC data in…
- CImg< >::load_inr(): INRIMAGE-4 header not found.
- load_analyze(): Cannot read header (of size %u) in file
- load_analyze(): Invalid header size (%u) specified in file
- load_ascii(): Invalid ascii header in file
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/c54ccbf875af9dab.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:67115
} break;
case 16 : {
CImg<ushortT> buf(size_x,size_y);
cimg::fread(buf._data,size_x*size_y,file2);
if (cimg::endianness()) cimg::invert_endianness(buf._data,size_x*size_y);
CImg<T>& img = (*this)[imn];
cimg_forXY(img,x,y) img(x,y,sn) = (T)(( buf(x,y)*rs + ri )/(rs*ss));
} break;
case 32 : {
CImg<uintT> buf(size_x,size_y);
cimg::fread(buf._data,size_x*size_y,file2);
if (cimg::endianness()) cimg::invert_endianness(buf._data,size_x*size_y);
CImg<T>& img = (*this)[imn];
cimg_forXY(img,x,y) img(x,y,sn) = (T)(( buf(x,y)*rs + ri )/(rs*ss));
} break;
default :
cimg::fclose(file);
cimg::fclose(file2);
throw CImgIOException(_cimglist_instance
"load_parrec(): Unsupported %d-bits pixel type for file '%s'.",
cimglist_instance,
pixsize,filename);
}
}
cimg::fclose(file);
cimg::fclose(file2);
if (!_width)
throw CImgIOException(_cimglist_instance
"load_parrec(): Failed to recognize valid PAR-REC data in file '%s'.",
cimglist_instance,
filename);
return *this;
}
//! Load a list from a PAR/REC (Philips) file \newinstance.
static CImgList<T> get_load_parrec(const char *const filename) {
return CImgList<T>().load_parrec(filename);View on GitHub (pinned to f788b534b4)