Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Added formats method to return supported image formats

givanz90d4f4c227c7
diff --git a/system/media/gd.php b/system/media/gd.php
index 9f64a06..47159a7 100755
--- a/system/media/gd.php
+++ b/system/media/gd.php
@@ -199,4 +199,29 @@ class Image {
}
}
}
+
+ public static function formats($format = false) {
+ $formats = [];
+ $info = gd_info();
+
+ foreach ([
+ 'JPEG Support' => 'jpg',
+ 'PNG Support' => 'png',
+ 'WebP Support' => 'webp',
+ 'AVIF Support' => 'avif',
+ 'WBMP Support' => 'wbmp',
+ 'GIF Create Support' => 'gif',
+ 'XBM Support"' => 'xbm',
+ ] as $name => $extension) {
+ if (isset($info[$name]) && $info[$name]) {
+ $formats[] = $extension;
+ }
+ }
+
+ if ($format) {
+ return in_array($format, $formats);
+ }
+
+ return $formats;
+ }
}
diff --git a/system/media/imagick.php b/system/media/imagick.php
index 9837e9a..3239883 100755
--- a/system/media/imagick.php
+++ b/system/media/imagick.php
@@ -158,4 +158,11 @@ class Image {
$this->image->cropImage($width, $height, $crop_x, $crop_y);
}
+
+ public static function formats($format = false) {
+ $formats = \Imagick::queryformats() ?? [];
+
+ //return array_map(fn($value) => strtolower($value), $info);
+ return array_map('strtolower', $formats);
+ }
}
diff --git a/system/media/mockup.php b/system/media/mockup.php
index a16d8e6..a18e4b0 100644
--- a/system/media/mockup.php
+++ b/system/media/mockup.php
@@ -67,4 +67,8 @@ class Image {
public function crop($topX, $topY, $bottomX, $bottomY) {
return false;
}
+
+ public static function formats($format = false) {
+ return [];
+ }
}