{"record":{"id":"ab0084153222918c","repo":"Intervention/image","slug":"failed-to-apply-class-unable-to-process-rotatio-ab0084","errorCode":null,"errorMessage":"Failed to apply {class}, unable to process rotation","messagePattern":"Failed to apply (.+?), unable to process rotation","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\ModifierException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Modifiers/OrientModifier.php","lineNumber":61,"sourceCode":"                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":43,"sourceCodeEnd":70,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Modifiers/OrientModifier.php#L43-L70","documentation":"During orient(), one of the native calls matched to the EXIF orientation value threw an ImagickException (rotateImage('#000', 90/180/270) and/or flopImage(), or the final setImageOrientation()), and the driver wraps it with previous preserved. The generic 'unable to process rotation' message hides the real reason, which is in the chained ImagickException. This branch is the typical one on modern ImageMagick builds because they throw rather than return false.","triggerScenarios":"$image->orient() on a photo with EXIF orientation 3/6/8 (180/90/270 rotation) where rotateImage throws: cache/resources exhausted, 'not authorized' policy error, or corrupted frame data from a partially downloaded upload.","commonSituations":"Upload pipelines auto-orienting phone photos under low memory_limit; Docker images based on distro packages with hardened policy.xml; animated files where orient() rotates the whole Imagick object frame list.","solutions":["Log $e->getPrevious()?->getMessage(); match on 'MemoryCache'/'not authorized' to pick the fix","Increase memory_limit or MAGICK_MEMORY_LIMIT / resource area in policy.xml for the rotated frame","Downscale before orient() if the source is a 12MP+ photo and full size is not needed","Verify the upload is complete (Content-Length vs actual bytes) since truncated files fail at operation time, not decode time"],"exampleFix":"// before\n$image->orient();\n\n// after\nuse Intervention\\Image\\Exceptions\\ModifierException;\n\ntry {\n    $image->orient();\n} catch (ModifierException $e) {\n    if (str_contains($e->getPrevious()?->getMessage() ?? '', 'memory')) {\n        ini_set('memory_limit', '512M');\n        $image->orient(); // retry once with more memory\n    } else {\n        throw $e;\n    }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"use Intervention\\Image\\Exceptions\\ModifierException;\n\ntry {\n    $image->orient();\n} catch (ModifierException $e) {\n    $msg = $e->getPrevious()?->getMessage() ?? '';\n    if (str_contains($msg, 'memory') || str_contains($msg, 'cache')) {\n        // retry with more headroom or a smaller decode\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Phone photos with orientation tags 5-8 trigger both a rotate and a flop; budget memory for a full frame copy","Watch for EXIF orientation on HEIC/AVIF-derived JPEGs; their large frames stress the same code path","Wrap orient() separately from other modifications so one failure does not discard the whole edit chain"],"tags":["php","imagick","intervention-image","exif","orientation","rotateimage"],"backgroundTag":"exif-orientation-failed","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}