summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/images.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/images.php b/src/images.php
index 0e09814..fea1825 100644
--- a/src/images.php
+++ b/src/images.php
@@ -45,4 +45,22 @@ function resize_image(string $src_path, string $dst_path, int $max_width, int $m
$imagick->destroy();
return null;
+}
+
+function get_mime_and_ext(string $src_path): array|null
+{
+ if ($src_path == "") {
+ return null;
+ }
+
+ $imagick = new Imagick();
+
+ $imagick->readImage($src_path);
+ $ext = strtolower($imagick->getImageFormat());
+ $mime = $imagick->getImageMimeType();
+
+ $imagick->clear();
+ $imagick->destroy();
+
+ return [$mime, $ext];
} \ No newline at end of file