{"record":{"id":"43edf7d37acbb5dc","repo":"Intervention/image","slug":"failed-to-set-adjust-image-orientation","errorCode":null,"errorMessage":"Failed to set adjust image orientation","messagePattern":"Failed to set adjust image orientation","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\ImageDecoderException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Decoders/NativeObjectDecoder.php","lineNumber":97,"sourceCode":"            if ($input->getImageColorspace() === Imagick::COLORSPACE_YCBCR) {\n                $input->transformImageColorspace(Imagick::COLORSPACE_SRGB);\n            }\n        } catch (ImagickException $e) {\n            throw new DriverException('Failed to convert image to sRGB', previous: $e);\n        }\n\n        // create image object\n        $image = new Image($this->driver(), new Core($input));\n\n        // If autoOrientation is disabled, automatic image alignment should be prevented.\n        // Therefore, it is set to \"undefined\" here. To still be able to correct the\n        // orientation manually later, we save the original value.\n        if ($this->driver()->config()->autoOrientation === false) {\n            try {\n                $image->core()->meta()->set('originalImageOrientation', $input->getImageOrientation());\n                $input->setImageOrientation(Imagick::ORIENTATION_UNDEFINED);\n            } catch (ImagickException $e) {\n                throw new ImageDecoderException(\n                    'Failed to set adjust image orientation',\n                    previous: $e,\n                );\n            }\n        }\n\n        // discard animation depending on config\n        if (!$this->driver()->config()->decodeAnimation) {\n            $image->modify(new RemoveAnimationModifier());\n        }\n\n        // adjust image rotation\n        if ($this->driver()->config()->autoOrientation) {\n            $image->modify(new OrientModifier());\n        }\n\n        // set media type on origin\n        $image->origin()->setMediaType($originalMimeType);","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Decoders/NativeObjectDecoder.php#L79-L115","documentation":"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.","triggerScenarios":"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.","commonSituations":"ICC/EXIF-preserving pipelines that disable auto-orientation, then feed stripped or metadata-less images; rare ImageMagick builds rejecting orientation writes for certain formats.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $image = $manager->read($path);\n} catch (\\Intervention\\Image\\Exceptions\\ImageDecoderException $e) {\n    $native = $e->getPrevious()?->getMessage() ?? 'unknown';\n    $logger->warning('Orientation handling failed: ' . $native);\n    throw $e;\n}","preventionTips":["Only disable autoOrientation when you truly need original EXIF preserved","Normalize or strip EXIF on ingest when metadata quality is untrusted"],"tags":["imagick","exif","orientation","auto-orientation","metadata"],"backgroundTag":"exif-orientation-metadata","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}