Intervention/image · error · Intervention\Image\Exceptions\AnalyzerException
Failed to read image resolution
Error message
Failed to read image resolution
What it means
$image->resolution() reads the DPI density via Imagick::getImageResolution(); an ImagickException there is wrapped into this AnalyzerException. Resolution metadata lives outside pixel data, so files with malformed or absent density records (some BMPs, aggregator-produced files, delegate-dependent formats) can trip the read even though pixels are fine.
Source
Thrown at src/Drivers/Imagick/Analyzers/ResolutionAnalyzer.php:29
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\SpecializedInterface;
use Intervention\Image\Length;
use Intervention\Image\Resolution;
class ResolutionAnalyzer extends GenericResolutionAnalyzer implements SpecializedInterface
{
/**
* @throws InvalidArgumentException
* @throws AnalyzerException
*/
public function analyze(ImageInterface $image): mixed
{
$imagick = $image->core()->native();
try {
$imageResolution = $imagick->getImageResolution();
} catch (ImagickException $e) {
throw new AnalyzerException('Failed to read image resolution', previous: $e);
}
return new Resolution(
$imageResolution['x'],
$imageResolution['y'],
$imagick->getImageUnits() === 2 ? Length::CM : Length::INCH,
);
}
}
View on GitHub (pinned to 5598b9e397)
Solutions
- Wrap resolution() in try/catch and default to 72 DPI when the metadata is unreadable.
- If a specific DPI is required downstream, set it explicitly with $image->setResolution($x, $y) instead of trusting the file.
- Inspect the odd file with identify -verbose to see whether a density record exists at all.
Example fix
// before
$resolution = $image->resolution();
// after: default to 72 DPI when metadata is unreadable
try {
$resolution = $image->resolution();
} catch (\Intervention\Image\Exceptions\AnalyzerException) {
$resolution = new \Intervention\Image\Resolution(72, 72, \Intervention\Image\Units\Length::INCH);
} Defensive patterns
Strategy: try-catch
Try / catch
try { $resolution = $image->resolution(); } catch (AnalyzerException) { $resolution = new \Intervention\Image\Resolution(72, 72, \Intervention\Image\Units\Length::INCH); } Prevention
- Treat DPI metadata as optional: always define a default resolution for your pipeline.
- Set the required DPI explicitly with setResolution() when it matters downstream.
When it happens
Trigger: resolution() on files whose density chunk is corrupt or zeroed; on images processed by tools that wrote invalid resolution fields; querying resolution for formats whose ImageMagick delegate does not supply density (SVG, raw).
Common situations: Print-oriented pipelines reading DPI from arbitrary user uploads; mixed-format archives.
Related errors
- Failed to apply {class}, unable to set image resolution
- Unable to read resolution from path
- No ICC profile found in image
- Failed to get image loop count
- Failed to retrieve image format
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/980092adc15f9987.
Report an issue: GitHub.