Intervention/image · error · Error

Call to undefined method Intervention\Image\Image::{name}()

Error message

Call to undefined method Intervention\Image\Image::{name}()

What it means

resolveDriver() throws this InvalidArgumentException when the string you passed as the driver IS a loadable class, but it does not implement Intervention\Image\Interfaces\DriverInterface (checked with is_subclass_of()). Only real driver implementations can be instantiated by the manager; the class you named exists but is the wrong kind of class.

Source

Thrown at src/AnimationFactory.php:166

        // return ready-made frame with all attributes
        return $image
            ->core()
            ->first()
            ->setDelay($delay)
            ->setDisposalMethod(DisposalMethod::BACKGROUND->value);
    }

    /**
     * Collect processing calls on frame images.
     *
     * @param array<null|array<mixed>> $arguments
     * @throws Error
     */
    public function __call(string $name, array $arguments): self
    {
        if (!method_exists(Image::class, $name)) {
            throw new Error('Call to undefined method ' . Image::class . '::' . $name . '()');
        }

        $this->processingCalls[$this->currentFrameNumber] = $name;
        $this->processingArguments[$this->currentFrameNumber] = $arguments;

        return $this;
    }
}

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Use the shipped drivers: Intervention\Image\Drivers\Gd\Driver::class or Intervention\Image\Drivers\Imagick\Driver::class
  2. Check the use statements — make sure you did not import Imagick or another class where the Driver was intended
  3. For custom drivers, add 'implements DriverInterface' and implement all interface methods, then pass YourDriver::class

Example fix

// before: the imagick extension class, not a driver
use Imagick;
$manager = new ImageManager(['driver' => Imagick::class]);

// after
use Intervention\Image\Drivers\Imagick\Driver;
$manager = new ImageManager(['driver' => Driver::class]);
Defensive patterns

Strategy: type-guard

Validate before calling

use Intervention\Image\Interfaces\DriverInterface;

if (is_string($driver) && !is_subclass_of($driver, DriverInterface::class)) {
    throw new \RuntimeException($driver . ' is not a driver; use Gd\Driver::class or Imagick\Driver::class');
}
$manager = new \Intervention\Image\ImageManager(['driver' => $driver]);

Type guard

use Intervention\Image\Interfaces\DriverInterface;

function isValidDriverClass(string $class): bool
{
    return class_exists($class) && is_subclass_of($class, DriverInterface::class);
}

Try / catch

use Intervention\Image\Exceptions\InvalidArgumentException;

try {
    $manager = new \Intervention\Image\ImageManager(['driver' => $candidate]);
} catch (InvalidArgumentException $e) {
    // message names DriverInterface: the class exists but is the wrong type — fix the config value
}

Prevention

When it happens

Trigger: new ImageManager(['driver' => \Imagick::class]) — passing the ext-imagick Imagick class instead of Intervention\Image\Drivers\Imagick\Driver::class; passing a related class like \Intervention\Image\ImageManager::class by mistake; a custom driver class that forgot to 'implements DriverInterface'; passing the abstract base decoder/driver classes from the wrong namespace.

Common situations: Confusing the PHP extension class (Imagick) with the library driver class; copy-paste of a use statement importing the similarly named class; writing a custom driver and skipping the interface; IDE auto-complete picking the wrong 'Driver' symbol.

Related errors


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