Intervention/image · error · EncoderException
Failed to encode tiff format
Error message
Failed to encode tiff format
What it means
The Imagick driver's TiffEncoder clones the native Imagick object, sets format 'TIFF' and then re-applies the compression read from the source image (setCompression(getImageCompression()) at src/Drivers/Imagick/Encoders/TiffEncoder.php:44-45), plus quality, before getImagesBlob(). Any ImagickException is rethrown as EncoderException ('Failed to encode tiff format') with the original as previous. Two typical roots: a TIFF write coder missing from a stripped build, or a compression carried over from the source that this ImageMagick cannot write into TIFF.
Source
Thrown at src/Drivers/Imagick/Encoders/TiffEncoder.php:54
if ($this->strip || (is_null($this->strip) && $this->driver()->config()->strip)) {
$image->modify(new StripMetaModifier());
}
try {
$imagick = clone $image->core()->native();
$imagick->setFormat($format);
$imagick->setImageFormat($format);
$imagick->setCompression($imagick->getImageCompression());
$imagick->setImageCompression($imagick->getImageCompression());
$imagick->setCompressionQuality($this->quality);
$imagick->setImageCompressionQuality($this->quality);
$result = new EncodedImage($imagick->getImagesBlob(), 'image/tiff');
$imagick->clear();
return $result;
} catch (ImagickException $e) {
throw new EncoderException('Failed to encode tiff format', previous: $e);
}
}
}
View on GitHub (pinned to 5598b9e397)
Solutions
- Read $e->getPrevious()->getMessage() - it names either the missing coder or the unsupported compression.
- Check Imagick::queryFormats('TIFF') on the failing host.
- Install libtiff-backed ImageMagick (standard distro package) and rebuild the imagick extension if the coder is missing.
- For compression conflicts, strip the source compression first: re-encode via toPng() then convert, or normalize the image (e.g. $image->toTiff() after a toPng()->toTiff() round trip) so no exotic codec carries over.
Example fix
// before
$tiff = $manager->read('scan-jbig.tif')->toTiff(); // carries JBIG compression into the writer
// after - normalize through an uncompressed intermediate
$png = $manager->read('scan-jbig.tif')->toPng();
$tiff = $manager->read($png->toPsrStream())->toTiff(); Defensive patterns
Strategy: try-catch
Validate before calling
if (!in_array('TIFF', Imagick::queryFormats('TIFF'), true)) {
throw new RuntimeException('TIFF encoding unavailable on this ImageMagick build');
} Try / catch
try {
$encoded = $image->toTiff();
} catch (EncoderException $e) {
$reason = $e->getPrevious()?->getMessage() ?? $e->getMessage();
// source compression may be unwritable for TIFF - normalize first
$encoded = $manager->read($image->toPng()->toPsrStream())->toTiff();
} Prevention
- Normalize exotic source formats through a PNG step before TIFF output to shed unsupported compressions.
- Verify TIFF coder presence with queryFormats on every host in the pipeline, not just the ingest node.
- Log getPrevious() to distinguish a missing coder from a compression the writer rejects.
When it happens
Trigger: Calling toTiff() on the Imagick driver when the TIFF coder is absent (php -r "var_dump((new Imagick())->queryFormats('TIFF'));" empty), or when the source image's compression (read at TiffEncoder.php:44) is one this build cannot write to TIFF, causing getImagesBlob() to fail.
Common situations: Print/imaging pipelines converting exotic-format sources (JBIG/proprietary compressions) to TIFF; minimal container builds without libtiff; mixed environments where decoding worked on one host and the encode job runs on another with fewer coders.
Related errors
- Failed to encode avif format
- Failed to encode bmp format
- Failed to encode heic format
- Failed to encode jp2 format
- Failed to encode jxl format
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/6b6e74322cac480d.
Report an issue: GitHub.