{"record":{"id":"958ebde39d6ecee5","repo":"Yalantis/uCrop","slug":"load-parrec-failed-to-recognize-valid-par-rec-d","errorCode":null,"errorMessage":"load_parrec(): Failed to recognize valid PAR-REC data in file '%s'.","messagePattern":"load_parrec\\(\\): Failed to recognize valid PAR-REC data in file '(.+?)'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":67124,"sourceCode":"          CImg<uintT> buf(size_x,size_y);\n          cimg::fread(buf._data,size_x*size_y,file2);\n          if (cimg::endianness()) cimg::invert_endianness(buf._data,size_x*size_y);\n          CImg<T>& img = (*this)[imn];\n          cimg_forXY(img,x,y) img(x,y,sn) = (T)(( buf(x,y)*rs + ri )/(rs*ss));\n        } break;\n        default :\n          cimg::fclose(file);\n          cimg::fclose(file2);\n          throw CImgIOException(_cimglist_instance\n                                \"load_parrec(): Unsupported %d-bits pixel type for file '%s'.\",\n                                cimglist_instance,\n                                pixsize,filename);\n        }\n      }\n      cimg::fclose(file);\n      cimg::fclose(file2);\n      if (!_width)\n        throw CImgIOException(_cimglist_instance\n                              \"load_parrec(): Failed to recognize valid PAR-REC data in file '%s'.\",\n                              cimglist_instance,\n                              filename);\n      return *this;\n    }\n\n    //! Load a list from a PAR/REC (Philips) file \\newinstance.\n    static CImgList<T> get_load_parrec(const char *const filename) {\n      return CImgList<T>().load_parrec(filename);\n    }\n\n    //! Load a list from a YUV image sequence file.\n    /**\n        \\param filename Filename to read data from.\n        \\param size_x Width of the images.\n        \\param size_y Height of the images.\n        \\param chroma_subsampling Type of chroma subsampling. Can be <tt>{ 420 | 422 | 444 }</tt>.\n        \\param first_frame Index of first image frame to read.","sourceCodeStart":67106,"sourceCodeEnd":67142,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L67106-L67142","documentation":"After parsing the PAR header and REC data, load_parrec() checks whether any image dimensions were actually set (_width). A zero width means the parser never recognized valid PAR/REC content, so CImg throws CImgIOException instead of returning an empty list.","triggerScenarios":"load_parrec() given a file that lacks the required PAR header keywords (e.g. '# Patients', '# Recon resolution', image info lines) so no image records are parsed; passing the .REC file instead of the .PAR text header; an empty or wrong-format file.","commonSituations":"Mixing up the .par and .rec files (the loader wants the .par header path); loading a renamed DICOM/NIfTI file with a .par extension; truncated downloads; PAR files from scanner versions with a header layout CImg cannot parse.","solutions":["Pass the .PAR header file (not the .REC binary) to load_parrec()","Open the file in a text editor and confirm it contains Philips PAR header blocks ('# Interested Eco lane', image lines, etc.)","Re-transfer/re-download the study - truncated files parse to zero images","If the format is a newer Philips revision, convert to NIfTI/DICOM externally or update CImg"],"exampleFix":"// before\nimgs.load_parrec(\"scan.rec\"); // binary data, no PAR header\n// after\nimgs.load_parrec(\"scan.par\"); // PAR text header (references scan.rec)","handlingStrategy":"validation","validationCode":"std::ifstream f(parPath); std::string line;\nbool isPar = false;\nwhile (std::getline(f, line)) if (line.rfind(\"# \", 0) == 0 && line.find(\"Philips\") != std::string::npos) { isPar = true; break; }\nif (!isPar) { /* not a PAR header - abort or convert */ }","typeGuard":null,"tryCatchPattern":"try { imgs.load_parrec(parPath); }\ncatch (CImgIOException& e) { fprintf(stderr, \"not a valid PAR file: %s\\n\", e.what()); }","preventionTips":["Always pass the .par header, never the .rec binary","Check the file's first lines look like a Philips PAR header before loading","Verify file sizes after transfer (truncation detection)"],"tags":["cimg","parrec","mri","file-format","empty-result"],"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-17T15:17:12.973Z"}