{"record":{"id":"d41aabb342ce7977","repo":"Yalantis/uCrop","slug":"load-pandore-pandore-header-not-found-in-file","errorCode":null,"errorMessage":"load_pandore(): PANDORE header not found in file '%s'.","messagePattern":"load_pandore\\(\\): PANDORE header not found in file '(.+?)'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":58852,"sourceCode":"        if (sizeof(stype1)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1); } \\\n        else if (sizeof(stype2)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype2); } \\\n        else if (sizeof(stype3)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype3); } \\\n        else throw CImgIOException(_cimg_instance \\\n                                   \"load_pandore(): Unknown pixel datatype in file '%s'.\", \\\n                                   cimg_instance, \\\n                                   filename?filename:\"(FILE*)\"); }\n      if (!file && !filename)\n        throw CImgArgumentException(_cimg_instance\n                                    \"load_pandore(): Specified filename is (null).\",\n                                    cimg_instance);\n\n      const ulongT fsiz = file?(ulongT)cimg_max_buf_size:(ulongT)cimg::fsize(filename);\n      std::FILE *const nfile = file?file:cimg::fopen(filename,\"rb\");\n      CImg<charT> header(32);\n      cimg::fread(header._data,12,nfile);\n      if (cimg::strncasecmp(\"PANDORE\",header,7)) {\n        if (!file) cimg::fclose(nfile);\n        throw CImgIOException(_cimg_instance\n                              \"load_pandore(): PANDORE header not found in file '%s'.\",\n                              cimg_instance,\n                              filename?filename:\"(FILE*)\");\n      }\n      unsigned int imageid, dims[8] = {};\n      int ptbuf[4] = {};\n      cimg::fread(&imageid,1,nfile);\n      const bool endian = imageid>255;\n      if (endian) cimg::invert_endianness(imageid);\n      cimg::fread(header._data,20,nfile);\n\n      switch (imageid) {\n      case 2 : _cimg_load_pandore_case(2,dims[1],1,1,1,unsigned char,unsigned char,unsigned char,1); break;\n      case 3 : _cimg_load_pandore_case(2,dims[1],1,1,1,long,int,short,4); break;\n      case 4 : _cimg_load_pandore_case(2,dims[1],1,1,1,double,float,float,4); break;\n      case 5 : _cimg_load_pandore_case(3,dims[2],dims[1],1,1,unsigned char,unsigned char,unsigned char,1); break;\n      case 6 : _cimg_load_pandore_case(3,dims[2],dims[1],1,1,long,int,short,4); break;\n      case 7 : _cimg_load_pandore_case(3,dims[2],dims[1],1,1,double,float,float,4); break;","sourceCodeStart":58834,"sourceCodeEnd":58870,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L58834-L58870","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nimg.load_pandore(maybe_pan); // throws if not PANDORE\n// after\nstd::ifstream in(maybe_pan, std::ios::binary);\nchar head[8] = {};\nin.read(head, 7);\nif (!in || cimg::strncasecmp(\"PANDORE\", head, 7))\n  img.load(maybe_pan);   // auto-detect instead\nelse\n  img.load_pandore(maybe_pan);","handlingStrategy":"validation","validationCode":"std::ifstream f(path, std::ios::binary);\nchar head[8] = {}; f.read(head, 7);\nif (!f || cimg::strncasecmp(\"PANDORE\", head, 7))\n  throw std::runtime_error(\"not a PANDORE file; use auto-detecting load()\");","typeGuard":null,"tryCatchPattern":"try { img.load_pandore(path); } catch (const cimg_library::CImgIOException &e) { /* bad header */ img.load(path); // auto-detect by magic bytes\n}","preventionTips":["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"],"tags":["cimg","image-loading","pandore","bad-file-format"],"backgroundTag":"file-not-found","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"}