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

Unable to create file extension from "{$identifier::class}"

Error message

Unable to create file extension from "{$identifier::class}"

What it means

Error "Unable to create file extension from "{$identifier::class}"" thrown in Intervention/image.

Source

Thrown at src/FileExtension.php:53

    case JXL = 'jxl';
    case ICO = 'ico';

    /**
     * Create file extension from given identifier.
     *
     * @throws InvalidArgumentException
     */
    public static function create(string|self|Format|MediaType $identifier): self
    {
        if ($identifier instanceof self) {
            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 {

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Pass a supported identifier: a file path string, a Format/FileExtension enum, or an object mappable to a known extension
  2. Check the given object's class against the formats supported by Intervention\Image (JPEG, PNG, GIF, WebP, AVIF, BMP, TIFF, HEIC)
  3. Use FileExtension::tryFrom() or Format lookups when the identifier type is dynamic

When it happens

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