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

Unable to retrieve unsupported file extension for format

Error message

Unable to retrieve unsupported file extension for format

What it means

Error "Unable to retrieve unsupported file extension for format" thrown in Intervention/image.

Source

Thrown at src/Format.php:142

        return array_filter(
            FileExtension::cases(),
            fn(FileExtension $fileExtension): bool => $fileExtension->format() === $this,
        );
    }

    /**
     * Return the first found file extension for the current format.
     *
     * @throws NotSupportedException
     */
    public function fileExtension(): FileExtension
    {
        $extensions = $this->fileExtensions();

        $result = reset($extensions);

        if (!$result instanceof FileExtension) {
            throw new NotSupportedException('Unable to retrieve unsupported file extension for format');
        }

        return $result;
    }

    /**
     * Create an encoder instance with given options that matches the format.
     */
    public function encoder(mixed ...$options): EncoderInterface
    {
        // get classname of target encoder from current format
        $classname = match ($this) {
            self::AVIF => AvifEncoder::class,
            self::BMP => BmpEncoder::class,
            self::GIF => GifEncoder::class,
            self::HEIC => HeicEncoder::class,
            self::ICO => IcoEncoder::class,
            self::JP2 => Jpeg2000Encoder::class,

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Call fileExtension() only for formats with a mapped extension; consult the Format enum cases for supported values
  2. Provide the extension explicitly when saving (e.g. ->save(path: 'out.jpg')) instead of deriving it from an unmapped format
  3. Check for typos in custom format identifiers before relying on automatic extension resolution

When it happens

Trigger: Thrown at src/Format.php:142 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/96792a418a0d18d7. Report an issue: GitHub.