Intervention / image

PHP Image Processing
https://image.intervention.io
MIT License
13.79k stars 1.5k forks source link

Method to check what formats are supported #1326

Closed GuySartorelli closed 3 months ago

GuySartorelli commented 3 months ago

Describe the feature you'd like A method that I can call which tells me either:

e.g.

use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver as GdDriver;

$manager = new ImageManager(new GdDriver());

$isSupported = $manager->supports('png'); // bool
$allSupported = $manager->getSupportedFormats(); // array

Imagick has Imagick::queryFormats() which provides this information, and GD has the imagetypes() function.

Even if it's not dynamically checking based on the above, intervention image does surely know what it can and can't support without relying on throwing exceptions?

Is your feature request related to a problem? Please describe. Right now I either have to call those methods directly or have a hardcoded list of formats. I'm currently writing an abstract file converter interface, and using intervention as a use case to make sure the API is fit for purpose. It's very frustrating that I need to define or find a list of supported formats on my own... this feels very much like something intervention image should be handling for me.

olivervogel commented 3 months ago

Sounds like a good idea. The library knows which formats are supported in the best case. However, the decisive factor is with which support the extension (GD or Imagick) was built. The functions mentioned can be used to check this.

I will look into this.

olivervogel commented 3 months ago

This feature is available as of version 3.6.0. See: https://image.intervention.io/v3/introduction/formats#check-the-support-for-image-formats