Intervention/image · error · ModifierException

Failed to apply Intervention\Image\Drivers\Imagick\Modifiers

Error message

Failed to apply Intervention\Image\Drivers\Imagick\Modifiers\CropModifier, unable to create new frame canvas

What it means

Error "Failed to apply Intervention\Image\Drivers\Imagick\Modifiers\CropModifier, unable to create new frame canvas" thrown in Intervention/image.

Source

Thrown at src/Drivers/Imagick/Modifiers/CropModifier.php:69

            ($crop->pivot()->x() + $this->x) * -1,
            ($crop->pivot()->y() + $this->y) * -1,
        ];

        foreach ($image as $frame) {
            // create new frame canvas with modifiers background
            try {
                $canvas = new Imagick();
                $canvas->newImage($crop->width(), $crop->height(), $background, 'png');
                $canvas->setImageResolution($resolution->x(), $resolution->y());
                $canvas->setImageAlphaChannel(Imagick::ALPHACHANNEL_SET); // or ALPHACHANNEL_ACTIVATE?
                $canvas->setImageColorspace(match ($image->colorspace()::class) {
                    Cmyk::class => Imagick::COLORSPACE_CMYK,
                    Hsv::class => Imagick::COLORSPACE_HSB,
                    Hsl::class => Imagick::COLORSPACE_HSL,
                    default => Imagick::COLORSPACE_SRGB,
                });
            } catch (ImagickException $e) {
                throw new ModifierException(
                    'Failed to apply ' . self::class . ', unable to create new frame canvas',
                    previous: $e,
                );
            }

            // set animation details
            if ($image->isAnimated()) {
                try {
                    $canvas->setImageDelay($frame->native()->getImageDelay());
                    $canvas->setImageIterations($frame->native()->getImageIterations());
                    $canvas->setImageDispose($frame->native()->getImageDispose());
                } catch (ImagickException $e) {
                    throw new ModifierException(
                        'Failed to apply ' . self::class . ', unable to set animation details',
                        previous: $e,
                    );
                }
            }

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Ensure the computed crop rectangle has a width and height of at least 1 pixel; coordinates outside the image can produce an empty canvas
  2. Validate the crop offset (x, y) combined with width/height so the resulting frame is not degenerate
  3. Confirm the source frame's Imagick instance is valid before creating the new frame canvas

When it happens

Trigger: Thrown at src/Drivers/Imagick/Modifiers/CropModifier.php:69 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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