{"record":{"id":"d3378c8df856b31e","repo":"Intervention/image","slug":"failed-to-apply-self-class-unable-to-re","errorCode":null,"errorMessage":"Failed to apply ' . self::class . ', unable to re-apply icc profile","messagePattern":"Failed to apply ' \\. self::class \\. ', unable to re-apply icc profile","errorType":"exception","errorClass":"ModifierException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Modifiers/StripMetaModifier.php","lineNumber":62,"sourceCode":"            throw new ModifierException(\n                'Failed to apply ' . self::class . ', unable to strip meta data',\n                previous: $e,\n            );\n        }\n\n        $image->setExif(new Collection());\n\n        if ($profiles !== []) {\n            // re-apply icc profiles\n            try {\n                $result = $image->core()->native()->profileImage(\"icc\", $profiles['icc']);\n                if ($result === false) {\n                    throw new ModifierException(\n                        'Failed to apply ' . self::class . ', unable to re-apply icc profile',\n                    );\n                }\n            } catch (ImagickException $e) {\n                throw new ModifierException(\n                    'Failed to apply ' . self::class . ', unable to re-apply icc profile',\n                    previous: $e,\n                );\n            }\n        }\n        return $image;\n    }\n}\n","sourceCodeStart":44,"sourceCodeEnd":71,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Modifiers/StripMetaModifier.php#L44-L71","documentation":"Final failure step of the Imagick StripMetaModifier, exception variant: profileImage('icc', ...) threw an ImagickException while re-attaching the preserved ICC profile after stripImage(). It is wrapped as ModifierException with the original attached. The message text in the source contains a concatenation placeholder, but the runtime message is 'Failed to apply ..., unable to re-apply icc profile'.","triggerScenarios":"$image->encode(new HeicEncoder(strip: true)) or any Imagick encoder with strip: true when profileImage() throws - invalid profile blob rejected by LCMS, memory limits, or wand invalidated by the preceding strip operation.","commonSituations":"Corrupt or non-conformant ICC profiles embedded in user uploads; processing pipelines that assume profiles are always valid; ImageMagick builds where LCMS validation is strict.","solutions":["Read getPrevious()->getMessage() for the LCMS/ImageMagick error detail","Check the source profile with external tooling and remove/replace it if malformed","Fall back to encoding without strip for the affected file and alert on it","Ensure ImageMagick and its LCMS delegate are up to date"],"exampleFix":"// before\n$encoded = $image->encode(new HeicEncoder(quality: 80, strip: true));\n\n// after\ntry {\n    $encoded = $image->encode(new HeicEncoder(quality: 80, strip: true));\n} catch (ModifierException $e) {\n    $reason = $e->getPrevious()?->getMessage() ?? $e->getMessage();\n    throw new RuntimeException(\"ICC profile re-apply failed: {$reason}\", 0, $e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"use Intervention\\Image\\Exceptions\\ModifierException;\n\ntry {\n    $encoded = $image->encode(new HeicEncoder(quality: 80, strip: true));\n} catch (ModifierException $e) {\n    $reason = $e->getPrevious()?->getMessage() ?? $e->getMessage();\n    throw new RuntimeException(\"ICC re-apply failed: {$reason}\", 0, $e);\n}","preventionTips":["Reject or sanitize uploads whose ICC profile fails 'identify -verbose' checks","Alert on recurring profile failures - they indicate a specific producer/tool in your input stream"],"tags":["imagick","icc-profile","color-profile","strip","encoding"],"backgroundTag":"imagick-operation-failed","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}