Intervention/image · warning · MissingDependencyException
Unable to read exif data
Error message
Unable to read exif data
What it means
The second resolution-recovery strategy needs PHP's exif_read_data() function; if function_exists('exif_read_data') is false, this MissingDependencyException is thrown instead of a fatal call to an undefined function. It indicates the ext-exif PHP extension is not loaded in the runtime. Like the other recovery failures it is caught by readResolutionFromOrigin()'s chain and analyze()'s catch (Throwable), so it does not escape the public API — it just means EXIF-based DPI recovery is unavailable.
Source
Thrown at src/Drivers/Gd/Analyzers/ResolutionAnalyzer.php:139
$y = unpack('n', substr($header, $offset + 10, 2))[1];
if ($units === 2) { // unit is dots per cm → convert to DPI
return [round($x * 2.54), round($y * 2.54)];
}
return [$x, $y]; // unit is DPI or no unit
}
/**
* @param resource $handle
* @throws MissingDependencyException
* @throws AnalyzerException
* @return array<float>
*/
private function resolutionFromExifHeader($handle): array
{
if (!function_exists('exif_read_data')) {
throw new MissingDependencyException('Unable to read exif data');
}
rewind($handle);
$data = @exif_read_data($handle, null, true);
if ($data === false) {
throw new AnalyzerException('Unable to read exif data');
}
if (isset($data['XResolution']) && isset($data['YResolution'])) {
$resolution = [$data['XResolution'], $data['YResolution']];
}
if (isset($data['IFD0']) && isset($data['IFD0']['XResolution']) && isset($data['IFD0']['YResolution'])) {
$resolution = [$data['IFD0']['XResolution'], $data['IFD0']['YResolution']];
}
if (!isset($resolution)) {View on GitHub (pinned to 5598b9e397)
Solutions
- Enable the exif extension: docker-php-ext-install exif (then rebuild the image), or apt install php8.x-exif
- Verify with php -m | grep exif or var_dump(function_exists('exif_read_data')) in the failing environment
- If you cannot change the runtime, accept the 96 DPI fallback or set resolution explicitly with setResolution()
Example fix
# before: Dockerfile FROM php:8.3-cli # after FROM php:8.3-cli RUN docker-php-ext-install exif
Defensive patterns
Strategy: validation
Validate before calling
if (!extension_loaded('exif') || !function_exists('exif_read_data')) {
// EXIF-based DPI recovery unavailable; plan for 96 DPI fallback or setResolution() explicitly
} Prevention
- Enable ext-exif in every environment that reads image resolution (dev, CI, prod parity)
- Verify with php -m | grep exif in Dockerfiles as a build-time check
- Document that GD resolution recovery degrades to 96 DPI without exif
When it happens
Trigger: Running the GD driver on a PHP build without ext-exif (minimal Docker images, default php:8.x-alpine) and calling resolution() on an image where GD returned its default 96 DPI.
Common situations: Alpine/slim Docker PHP images that ship neither exif nor fileinfo by default; shared hosts with a fixed extension list; CI environments differing from production.
Related errors
- Unable to read exif data, division by zero
- Failed to read image resolution
- Unable to read resolution from path
- Unable to read JFIF header
- Input must be PNG format
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/d8410b56a7503f47.
Report an issue: GitHub.