Intervention/image · error · Intervention\Image\Exceptions\ImageDecoderException
Failed to set adjust image orientation
Error message
Failed to set adjust image orientation
What it means
Only thrown when the driver is configured with autoOrientation => false. In that mode the decoder stores the original EXIF orientation in image metadata and resets the Imagick orientation to undefined; if getImageOrientation()/setImageOrientation() fail, this ImageDecoderException is thrown with the native error chained. With the default configuration (autoOrientation true) this code path never executes.
Source
Thrown at src/Drivers/Imagick/Decoders/NativeObjectDecoder.php:97
if ($input->getImageColorspace() === Imagick::COLORSPACE_YCBCR) {
$input->transformImageColorspace(Imagick::COLORSPACE_SRGB);
}
} catch (ImagickException $e) {
throw new DriverException('Failed to convert image to sRGB', previous: $e);
}
// create image object
$image = new Image($this->driver(), new Core($input));
// If autoOrientation is disabled, automatic image alignment should be prevented.
// Therefore, it is set to "undefined" here. To still be able to correct the
// orientation manually later, we save the original value.
if ($this->driver()->config()->autoOrientation === false) {
try {
$image->core()->meta()->set('originalImageOrientation', $input->getImageOrientation());
$input->setImageOrientation(Imagick::ORIENTATION_UNDEFINED);
} catch (ImagickException $e) {
throw new ImageDecoderException(
'Failed to set adjust image orientation',
previous: $e,
);
}
}
// discard animation depending on config
if (!$this->driver()->config()->decodeAnimation) {
$image->modify(new RemoveAnimationModifier());
}
// adjust image rotation
if ($this->driver()->config()->autoOrientation) {
$image->modify(new OrientModifier());
}
// set media type on origin
$image->origin()->setMediaType($originalMimeType);View on GitHub (pinned to 5598b9e397)
Solutions
- Check $e->getPrevious() for the native reason
- If preserving original orientation is not strictly required, leave autoOrientation at its default true
- Strip/normalize EXIF at the source when the metadata block is corrupt
- Upgrade ImageMagick if the format's orientation property is unsupported
Defensive patterns
Strategy: try-catch
Try / catch
try {
$image = $manager->read($path);
} catch (\Intervention\Image\Exceptions\ImageDecoderException $e) {
$native = $e->getPrevious()?->getMessage() ?? 'unknown';
$logger->warning('Orientation handling failed: ' . $native);
throw $e;
} Prevention
- Only disable autoOrientation when you truly need original EXIF preserved
- Normalize or strip EXIF on ingest when metadata quality is untrusted
When it happens
Trigger: new ImageManager(['driver' => 'imagick', 'autoOrientation' => false]) reading an image whose orientation metadata is damaged or absent, or an Imagick object in a state where writing properties fails.
Common situations: ICC/EXIF-preserving pipelines that disable auto-orientation, then feed stripped or metadata-less images; rare ImageMagick builds rejecting orientation writes for certain formats.
Related errors
- Failed to apply {class}, unable to process rotation of image
- Failed to apply {class}, unable to process rotation
- No ICC profile found in image
- Failed to read image resolution
- Failed to get image loop count
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/43edf7d37acbb5dc.
Report an issue: GitHub.