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

Failed to apply {class}, unable to strip meta data

Error message

Failed to apply {class}, unable to strip meta data

What it means

Second failure step of the Imagick StripMetaModifier: after the ICC profile was read successfully, Imagick::stripImage() returned false instead of true, so the metadata removal did not happen and the modifier aborts with ModifierException. A false return means ImageMagick could not strip metadata from the current image object.

Source

Thrown at src/Drivers/Imagick/Modifiers/StripMetaModifier.php:39

     * @throws ModifierException
     */
    public function apply(ImageInterface $image): ImageInterface
    {
        // preserve icc profiles
        try {
            $profiles = $image->core()->native()->getImageProfiles('icc');
        } catch (ImagickException $e) {
            throw new ModifierException(
                'Failed to apply ' . self::class . ', unable to preserve icc profiles',
                previous: $e,
            );
        }

        // remove meta data
        try {
            $result = $image->core()->native()->stripImage();
            if ($result === false) {
                throw new ModifierException(
                    'Failed to apply ' . self::class . ', unable to strip meta data',
                );
            }
        } catch (ImagickException $e) {
            throw new ModifierException(
                'Failed to apply ' . self::class . ', unable to strip meta data',
                previous: $e,
            );
        }

        $image->setExif(new Collection());

        if ($profiles !== []) {
            // re-apply icc profiles
            try {
                $result = $image->core()->native()->profileImage("icc", $profiles['icc']);
                if ($result === false) {
                    throw new ModifierException(

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Read any previous exception and the exact source file; retry with the same file in the imagick CLI to confirm
  2. Encode without strip: true to verify only the strip step is failing
  3. Re-save the image through an external tool first, then strip again
  4. Update ImageMagick if the file works on a newer version

Example fix

// before
$encoded = $image->encode(new JpegEncoder(quality: 90, strip: true));

// after
try {
    $encoded = $image->encode(new JpegEncoder(quality: 90, strip: true));
} catch (ModifierException $e) {
    $logger->warning('stripImage failed: ' . $e->getMessage());
    $encoded = $image->encode(new JpegEncoder(quality: 90));
}
Defensive patterns

Strategy: try-catch

Try / catch

use Intervention\Image\Exceptions\ModifierException;

try {
    $encoded = $image->encode(new JpegEncoder(quality: 90, strip: true));
} catch (ModifierException $e) {
    $encoded = $image->encode(new JpegEncoder(quality: 90));
}

Prevention

When it happens

Trigger: $image->encode(new JpegEncoder(quality: 90, strip: true)) or any Imagick encoder with strip: true when stripImage() returns false - frames with no writable metadata blocks, read-only/invalid wand state, or ImageMagick refusing to strip certain formats.

Common situations: Stripping metadata from images that were re-encoded several times; source formats with unusual metadata containers; ImageMagick version differences in what stripImage() accepts.

Related errors


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