Yalantis/uCrop · error · CImgIOException
load_pandore(): PANDORE header not found in file '%s'.
Error message
load_pandore(): PANDORE header not found in file '%s'.
What it means
PANDORE files begin with a magic header containing the string "PANDORE" within the first bytes. _load_pandore() reads 12 bytes and case-insensitively compares the first 7 with "PANDORE"; on mismatch it throws CImgIOException. This is a format-detection failure — the file is not a PANDORE file (or is unreadable/empty).
Source
Thrown at ucrop/src/main/jni/CImg.h:58852
if (sizeof(stype1)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1); } \
else if (sizeof(stype2)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype2); } \
else if (sizeof(stype3)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype3); } \
else throw CImgIOException(_cimg_instance \
"load_pandore(): Unknown pixel datatype in file '%s'.", \
cimg_instance, \
filename?filename:"(FILE*)"); }
if (!file && !filename)
throw CImgArgumentException(_cimg_instance
"load_pandore(): Specified filename is (null).",
cimg_instance);
const ulongT fsiz = file?(ulongT)cimg_max_buf_size:(ulongT)cimg::fsize(filename);
std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
CImg<charT> header(32);
cimg::fread(header._data,12,nfile);
if (cimg::strncasecmp("PANDORE",header,7)) {
if (!file) cimg::fclose(nfile);
throw CImgIOException(_cimg_instance
"load_pandore(): PANDORE header not found in file '%s'.",
cimg_instance,
filename?filename:"(FILE*)");
}
unsigned int imageid, dims[8] = {};
int ptbuf[4] = {};
cimg::fread(&imageid,1,nfile);
const bool endian = imageid>255;
if (endian) cimg::invert_endianness(imageid);
cimg::fread(header._data,20,nfile);
switch (imageid) {
case 2 : _cimg_load_pandore_case(2,dims[1],1,1,1,unsigned char,unsigned char,unsigned char,1); break;
case 3 : _cimg_load_pandore_case(2,dims[1],1,1,1,long,int,short,4); break;
case 4 : _cimg_load_pandore_case(2,dims[1],1,1,1,double,float,float,4); break;
case 5 : _cimg_load_pandore_case(3,dims[2],dims[1],1,1,unsigned char,unsigned char,unsigned char,1); break;
case 6 : _cimg_load_pandore_case(3,dims[2],dims[1],1,1,long,int,short,4); break;
case 7 : _cimg_load_pandore_case(3,dims[2],dims[1],1,1,double,float,float,4); break;View on GitHub (pinned to f788b534b4)
Solutions
- Confirm the file really is PANDORE format (open the first bytes; they must contain "PANDORE")
- Use the correct loader (load(), load_other(), load_png/jpeg...) — CImg's load() auto-detects by magic bytes
- Re-download/re-export the file if it is truncated or empty
- Check file permissions/size before loading
Example fix
// before
img.load_pandore(maybe_pan); // throws if not PANDORE
// after
std::ifstream in(maybe_pan, std::ios::binary);
char head[8] = {};
in.read(head, 7);
if (!in || cimg::strncasecmp("PANDORE", head, 7))
img.load(maybe_pan); // auto-detect instead
else
img.load_pandore(maybe_pan); Defensive patterns
Strategy: validation
Validate before calling
std::ifstream f(path, std::ios::binary);
char head[8] = {}; f.read(head, 7);
if (!f || cimg::strncasecmp("PANDORE", head, 7))
throw std::runtime_error("not a PANDORE file; use auto-detecting load()"); Try / catch
try { img.load_pandore(path); } catch (const cimg_library::CImgIOException &e) { /* bad header */ img.load(path); // auto-detect by magic bytes
} Prevention
- Prefer CImg's load() auto-detection over format-specific loaders when format is uncertain
- Check file size > 0 and header magic before dedicated loaders
- Never rename files across formats without converting
When it happens
Trigger: Loading a file that is not actually PANDORE format (renamed JPEG/PNG/text); loading an empty or truncated file (fewer than 12 bytes); a corrupted header.
Common situations: Wrong file selected by wildcard/glob; files renamed with .pan extension without conversion; interrupted writes producing empty files; using load_pandore when the format is actually another CImg loader's job.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- load_pandore(): File size %lu for filename '%s' does not mat
- load_pandore(): Unknown pixel datatype in file '%s'.
- load_pandore(): Specified filename is (null).
- load_pandore(): Unable to load data with ID_type %u in file
- load(): Failed to open file '%s'.
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/d41aabb342ce7977.
Report an issue: GitHub.