File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -320,6 +320,21 @@ public static function isTypeSupported(int $type): bool
320320 }
321321
322322
323+ /** @return ImageType[] */
324+ public static function getSupportedTypes (): array
325+ {
326+ $ flag = imagetypes ();
327+ return array_filter ([
328+ $ flag & IMG_GIF ? ImageType::GIF : null ,
329+ $ flag & IMG_JPG ? ImageType::JPEG : null ,
330+ $ flag & IMG_PNG ? ImageType::PNG : null ,
331+ $ flag & IMG_WEBP ? ImageType::WEBP : null ,
332+ $ flag & 256 ? ImageType::AVIF : null , // IMG_AVIF
333+ $ flag & IMG_BMP ? ImageType::BMP : null ,
334+ ]);
335+ }
336+
337+
323338 /**
324339 * Wraps GD image.
325340 */
Original file line number Diff line number Diff line change @@ -17,3 +17,5 @@ Assert::true(Image::isTypeSupported(Image::GIF));
1717Assert::true (Image::isTypeSupported (Image::JPEG ));
1818Assert::same (function_exists ('imagecreatefromwebp ' ), Image::isTypeSupported (Image::WEBP ));
1919Assert::same (function_exists ('imagecreatefromavif ' ), Image::isTypeSupported (Image::AVIF ));
20+
21+ Assert::contains (Image::GIF , Image::getSupportedTypes ());
You can’t perform that action at this time.
0 commit comments