{"record":{"id":"b87605961f1abd58","repo":"Intervention/image","slug":"failed-to-apply-class-unable-to-process-rotatio","errorCode":null,"errorMessage":"Failed to apply {class}, unable to process rotation of image","messagePattern":"Failed to apply (.+?), unable to process rotation of image","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\ModifierException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Modifiers/OrientModifier.php","lineNumber":56,"sourceCode":"                => $image->core()->native()->rotateImage('#000', 90) && $image->core()->native()->flopImage(), // 5\n\n                Imagick::ORIENTATION_RIGHTTOP\n                => $image->core()->native()->rotateImage('#000', 90), // 6\n\n                Imagick::ORIENTATION_RIGHTBOTTOM\n                => $image->core()->native()->rotateImage('#000', 270) && $image->core()->native()->flopImage(), // 7\n\n                Imagick::ORIENTATION_LEFTBOTTOM\n                => $image->core()->native()->rotateImage('#000', 270), // 8\n\n                default => 'value',\n            };\n\n            // set new orientation in image\n            $result = $result && $image->core()->native()->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);\n\n            if ($result === false) {\n                throw new ModifierException(\n                    'Failed to apply ' . self::class . ', unable to process rotation of image',\n                );\n            }\n        } catch (ImagickException $e) {\n            throw new ModifierException(\n                'Failed to apply ' . self::class . ', unable to process rotation',\n                previous: $e,\n            );\n        }\n\n        return $image;\n    }\n}\n","sourceCodeStart":38,"sourceCodeEnd":70,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Modifiers/OrientModifier.php#L38-L70","documentation":"orient() reads the frame's EXIF orientation (falling back to the originalImageOrientation metadata when Imagick reports ORIENTATION_UNDEFINED), then applies a flop/rotate combination for tags 2-8. This exception fires when one of those native calls (flopImage, rotateImage, or the trailing setImageOrientation(ORIENTATION_TOPLE)) returns false, leaving $result false. Orientations 1/undefined hit the 'default' arm, which returns a truthy string, so normal upright images never reach this throw.","triggerScenarios":"$image->orient() on an image whose EXIF orientation is 2-8 (mirrored/rotated phone photos) while the underlying flopImage()/rotateImage()/setImageOrientation() returns false, e.g. policy-restricted operations or an exhausted pixel cache.","commonSituations":"Processing smartphone JPEGs/HEIC-to-JPEG exports that carry orientation tags on a server whose ImageMagick policy.xml is tightened; large portrait photos rotated 90/270 degrees where rotation reallocates the full frame.","solutions":["Read $e->getPrevious()?->getMessage() to see which native op refused and why","Check /etc/ImageMagick-*/policy.xml for denied rotate/flop operations and allow them if you administer the host","Raise PHP memory_limit for large photos since rotation of 90/270 tags reallocates the frame","Strip the orientation beforehand as a workaround: re-encode via ImageMagick CLI ('convert -auto-orient') and re-ingest the file"],"exampleFix":"// before\n$image->orient();\n\n// after\nuse Intervention\\Image\\Exceptions\\ModifierException;\n\ntry {\n    $image->orient();\n} catch (ModifierException $e) {\n    $logger->warning('Auto-orient failed, serving unrotated image', [\n        'reason' => $e->getPrevious()?->getMessage(),\n    ]); // orientation stays as-is, image is still usable\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"use Intervention\\Image\\Exceptions\\ModifierException;\n\ntry {\n    $image->orient();\n} catch (ModifierException $e) {\n    $logger->warning('Auto-orient failed; using unrotated frame', [\n        'reason' => $e->getPrevious()?->getMessage(),\n    ]); // image remains usable, just not physically rotated","preventionTips":["Treat orient() as best-effort for user content; a failed orient should degrade, not abort, the pipeline","On policy-restricted hosts, pre-orient with 'convert -auto-orient' at upload time instead","Load big photos at reduced size first (e.g. via decode options) when orientation is all you need to fix"],"tags":["php","imagick","intervention-image","exif","orientation","flopimage"],"backgroundTag":"exif-orientation-failed","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}