{"record":{"id":"4b3a7e5565d6dabc","repo":"Intervention/image","slug":"failed-to-apply-class-unable-to-remove-icc-colo","errorCode":null,"errorMessage":"Failed to apply {class}, unable to remove ICC color profile","messagePattern":"Failed to apply (.+?), unable to remove ICC color profile","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\ModifierException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Modifiers/RemoveProfileModifier.php","lineNumber":25,"sourceCode":"use ImagickException;\nuse Intervention\\Image\\Exceptions\\ModifierException;\nuse Intervention\\Image\\Interfaces\\ImageInterface;\nuse Intervention\\Image\\Interfaces\\SpecializedInterface;\nuse Intervention\\Image\\Modifiers\\RemoveProfileModifier as GenericRemoveProfileModifier;\n\nclass RemoveProfileModifier extends GenericRemoveProfileModifier implements SpecializedInterface\n{\n    /**\n     * @throws ModifierException\n     */\n    public function apply(ImageInterface $image): ImageInterface\n    {\n        $imagick = $image->core()->native();\n\n        try {\n            $result = $imagick->profileImage('icc', null);\n            if ($result === false) {\n                throw new ModifierException(\n                    'Failed to apply ' . self::class . ', unable to remove ICC color profile',\n                );\n            }\n        } catch (ImagickException $e) {\n            throw new ModifierException(\n                'Failed to apply ' . self::class . ', unable to remove ICC color profile',\n                previous: $e,\n            );\n        }\n\n        return $image;\n    }\n}\n","sourceCodeStart":7,"sourceCodeEnd":39,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Modifiers/RemoveProfileModifier.php#L7-L39","documentation":"removeProfile() calls Imagick::profileImage('icc', null), where a null profile name-value removes that profile from the image; a false return triggers this ModifierException. Removal requires ImageMagick to parse the embedded profile first, so a corrupt embedded ICC or a build without proper profile support can make even deletion fail. This false branch is the uncommon path; native failures usually throw instead.","triggerScenarios":"$image->removeProfile() on an image whose embedded ICC chunk is malformed, so ImageMagick cannot parse-and-drop it; stripped-down ImageMagick builds without LCMS/profile support.","commonSituations":"Stripping profiles before re-encoding user uploads for size; JPEGs edited by tools that wrote broken APP2 ICC segments; minimal Docker images with hand-compiled ImageMagick.","solutions":["Read the previous exception (null here) or re-run with the Imagick CLI ('identify -verbose') to see how ImageMagick parses the file's profiles","Re-encode the file once via ImageMagick CLI to normalize/strip broken metadata, then retry removeProfile()","Use an ImageMagick build with profile support (distro packages); verify with convert -list configure | grep -i lcms","If only size reduction matters, encode to a format/encoder that drops profiles anyway and skip the explicit removal"],"exampleFix":"// before\n$image->removeProfile();\n\n// after\nuse Intervention\\Image\\Exceptions\\ModifierException;\n\ntry {\n    $image->removeProfile();\n} catch (ModifierException $e) {\n    $logger->warning('Could not strip ICC profile; continuing with it'); // profile stays, output still produced\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"use Intervention\\Image\\Exceptions\\ModifierException;\n\ntry {\n    $image->removeProfile();\n} catch (ModifierException $e) {\n    $logger->warning('ICC removal failed; encoding with profile retained'); // non-fatal for most web pipelines\n}","preventionTips":["Treat profile stripping as best-effort; make the encode step independent of it","Normalize third-party files through an ImageMagick CLI pass once if broken ICC segments recur","Verify delegate support on minimal/container ImageMagick builds before promising profile operations"],"tags":["php","imagick","intervention-image","icc-profile","metadata","strip-profile"],"backgroundTag":"icc-profile-removal-failed","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}