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

Unable to create file extension from "{$identifier->value}"

Error message

Unable to create file extension from "{$identifier->value}"

What it means

Error "Unable to create file extension from "{$identifier->value}"" thrown in Intervention/image.

Source

Thrown at src/FileExtension.php:64

            return $identifier;
        }

        if ($identifier instanceof Format) {
            try {
                return $identifier->fileExtension();
            } catch (NotSupportedException $e) {
                throw new InvalidArgumentException(
                    'Unable to create file extension from "' . $identifier::class . '"',
                    previous: $e,
                );
            }
        }

        if ($identifier instanceof MediaType) {
            try {
                return $identifier->fileExtension();
            } catch (NotSupportedException $e) {
                throw new InvalidArgumentException(
                    'Unable to create file extension from "' . $identifier->value . '"',
                    previous: $e,
                );
            }
        }

        try {
            $extension = self::from(strtolower($identifier));
        } catch (Error) {
            try {
                $extension = MediaType::from(strtolower($identifier))->fileExtension();
            } catch (Error | NotSupportedException) {
                throw new InvalidArgumentException('Unable to create file extension from "' . $identifier . '"');
            }
        }

        return $extension;
    }

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Use one of the backed enum values that maps to a known file extension, e.g. Format::JPEG->value
  2. Check spelling/casing of the media type or format string passed to the enum
  3. Extend the mapping only via supported formats; unknown enum values cannot be converted to an extension

When it happens

Trigger: Thrown at src/FileExtension.php:64 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/711c06921bf97f2d. Report an issue: GitHub.