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

Decoder must implement Intervention\Image\Interfaces\Decoder

Error message

Decoder must implement Intervention\Image\Interfaces\DecoderInterface

What it means

Error "Decoder must implement Intervention\Image\Interfaces\DecoderInterface" thrown in Intervention/image.

Source

Thrown at src/InputHandler.php:146

     */
    private function decoders(): Generator
    {
        foreach ($this->decoders as $decoder) {
            yield $this->decoder($decoder);
        }
    }

    /**
     * Resolve the given classname or object to a decoder object.
     *
     * @throws InvalidArgumentException
     * @throws DriverException
     */
    private function decoder(string|DecoderInterface $decoder): DecoderInterface
    {
        if (is_string($decoder)) {
            if (!is_subclass_of($decoder, DecoderInterface::class)) {
                throw new InvalidArgumentException('Decoder must implement ' . DecoderInterface::class);
            }

            $decoder = new $decoder();
        }

        if ($this->driver === null) {
            return $decoder;
        }

        try {
            return $this->driver->specializeDecoder($decoder);
        } catch (NotSupportedException $e) {
            throw new DriverException(
                'Failed to resolve decoder ' . $decoder::class . ' with driver ' . $this->driver::class,
                previous: $e,
            );
        }
    }

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Ensure the custom decoder class implements Intervention\Image\Interfaces\DecoderInterface
  2. Check the use-statement/namespace of your decoder so the correct interface is implemented
  3. Register decoders as class names of valid implementations, not arbitrary callables

When it happens

Trigger: Thrown at src/InputHandler.php:146 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/eed4f88abcbaf283. Report an issue: GitHub.