Intervention/image · warning · AnalyzerException

Unable to read resolution from path

Error message

Unable to read resolution from path

What it means

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.

Source

Thrown at src/Drivers/Gd/Analyzers/ResolutionAnalyzer.php:95

            try {
                return $this->resolutionFromJfifHeader($handle);
            } catch (Throwable) {
                # code ...
            }

            try {
                return $this->resolutionFromExifHeader($handle);
            } catch (Throwable) {
                # code ...
            }

            try {
                return $this->resolutionFromPngPhys($handle);
            } catch (Throwable) {
                # code ...
            }

            throw new AnalyzerException('Unable to read resolution from path');
        } finally {
            fclose($handle);
        }
    }

    /**
     * @param resource $handle
     * @throws AnalyzerException
     * @return array<float>
     */
    private function resolutionFromJfifHeader($handle): array
    {
        // read first 20 bytes
        rewind($handle);
        $header = fread($handle, 20);

        // find the JFIF segment
        $offset = strpos($header, 'JFIF');

View on GitHub (pinned to 5598b9e397)

Solutions

  1. No action needed if you used resolution(): the library already falls back to GD's default 96 DPI
  2. If exact DPI matters, set it explicitly with $image->setResolution($x, $y) from known source data
  3. Re-encode the source with density metadata (e.g. convert -density 72 in.jpg out.jpg) if you need origin recovery to succeed
  4. Keep origin files readable until all analysis is done; do not unlink() uploads mid-pipeline
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: 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).

Common situations: Processing WebP conversions that dropped metadata; temp files deleted before resolution() is called; images exported from tools that omit density information entirely.

Related errors


AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23). Data as JSON: /api/errors/1c48cadbe191e883. Report an issue: GitHub.