{"record":{"id":"1c48cadbe191e883","repo":"Intervention/image","slug":"unable-to-read-resolution-from-path","errorCode":null,"errorMessage":"Unable to read resolution from path","messagePattern":"Unable to read resolution from path","errorType":"exception","errorClass":"AnalyzerException","httpStatus":null,"severity":"warning","filePath":"src/Drivers/Gd/Analyzers/ResolutionAnalyzer.php","lineNumber":95,"sourceCode":"            try {\n                return $this->resolutionFromJfifHeader($handle);\n            } catch (Throwable) {\n                # code ...\n            }\n\n            try {\n                return $this->resolutionFromExifHeader($handle);\n            } catch (Throwable) {\n                # code ...\n            }\n\n            try {\n                return $this->resolutionFromPngPhys($handle);\n            } catch (Throwable) {\n                # code ...\n            }\n\n            throw new AnalyzerException('Unable to read resolution from path');\n        } finally {\n            fclose($handle);\n        }\n    }\n\n    /**\n     * @param resource $handle\n     * @throws AnalyzerException\n     * @return array<float>\n     */\n    private function resolutionFromJfifHeader($handle): array\n    {\n        // read first 20 bytes\n        rewind($handle);\n        $header = fread($handle, 20);\n\n        // find the JFIF segment\n        $offset = strpos($header, 'JFIF');","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Gd/Analyzers/ResolutionAnalyzer.php#L77-L113","documentation":"When GD reports its default 96x96 DPI and the image resolution was never changed, the analyzer tries to recover the true resolution from the origin file by parsing, in order: the JFIF header, EXIF data, and the PNG pHYs chunk. This error means all three parsers failed and the origin-based recovery is abandoned. It is thrown inside readResolutionFromOrigin(), whose caller analyze() wraps it in catch (Throwable) and falls back to [96, 96], so through the public resolution() API it is normally swallowed and never reaches user code.","triggerScenarios":"Images whose origin format stores no DPI (WebP, BMP, GIF origins), JPEGs with neither a JFIF density field nor EXIF XResolution/YResolution, PNGs without a pHYs chunk, or an origin file path that can no longer be read (deleted/moved temp upload).","commonSituations":"Processing WebP conversions that dropped metadata; temp files deleted before resolution() is called; images exported from tools that omit density information entirely.","solutions":["No action needed if you used resolution(): the library already falls back to GD's default 96 DPI","If exact DPI matters, set it explicitly with $image->setResolution($x, $y) from known source data","Re-encode the source with density metadata (e.g. convert -density 72 in.jpg out.jpg) if you need origin recovery to succeed","Keep origin files readable until all analysis is done; do not unlink() uploads mid-pipeline"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["The library already falls back to 96 DPI; only inspect this path when exact DPI matters","Keep origin files on disk until processing completes so origin recovery can read them","Prefer setResolution() with authoritative values over relying on origin recovery"],"tags":["gd","resolution","metadata","origin-file","fallback"],"backgroundTag":"image-metadata-unreadable","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}