Intervention/image · error · Intervention\Image\Exceptions\ModifierException

Failed to apply {class}, unable to remove ICC color profile

Error message

Failed to apply {class}, unable to remove ICC color profile

What it means

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.

Source

Thrown at src/Drivers/Imagick/Modifiers/RemoveProfileModifier.php:25

use ImagickException;
use Intervention\Image\Exceptions\ModifierException;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\SpecializedInterface;
use Intervention\Image\Modifiers\RemoveProfileModifier as GenericRemoveProfileModifier;

class RemoveProfileModifier extends GenericRemoveProfileModifier implements SpecializedInterface
{
    /**
     * @throws ModifierException
     */
    public function apply(ImageInterface $image): ImageInterface
    {
        $imagick = $image->core()->native();

        try {
            $result = $imagick->profileImage('icc', null);
            if ($result === false) {
                throw new ModifierException(
                    'Failed to apply ' . self::class . ', unable to remove ICC color profile',
                );
            }
        } catch (ImagickException $e) {
            throw new ModifierException(
                'Failed to apply ' . self::class . ', unable to remove ICC color profile',
                previous: $e,
            );
        }

        return $image;
    }
}

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Read the previous exception (null here) or re-run with the Imagick CLI ('identify -verbose') to see how ImageMagick parses the file's profiles
  2. Re-encode the file once via ImageMagick CLI to normalize/strip broken metadata, then retry removeProfile()
  3. Use an ImageMagick build with profile support (distro packages); verify with convert -list configure | grep -i lcms
  4. If only size reduction matters, encode to a format/encoder that drops profiles anyway and skip the explicit removal

Example fix

// before
$image->removeProfile();

// after
use Intervention\Image\Exceptions\ModifierException;

try {
    $image->removeProfile();
} catch (ModifierException $e) {
    $logger->warning('Could not strip ICC profile; continuing with it'); // profile stays, output still produced
}
Defensive patterns

Strategy: try-catch

Try / catch

use Intervention\Image\Exceptions\ModifierException;

try {
    $image->removeProfile();
} catch (ModifierException $e) {
    $logger->warning('ICC removal failed; encoding with profile retained'); // non-fatal for most web pipelines
}

Prevention

When it happens

Trigger: $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.

Common situations: 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.

Related errors


AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23). Data as JSON: /api/errors/4b3a7e5565d6dabc. Report an issue: GitHub.