diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-19 17:27:12 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-19 17:27:12 +0500 |
| commit | 7a66de9852d4683a7b5cdcedb8e88cfdc73f4b56 (patch) | |
| tree | 70437ad219721c0e74252ed51775142ca2f8b416 /src | |
| parent | 9c2f42e423096bdf56b7f96e07221f6420b0e337 (diff) | |
feat: extract extension and mime from image
Diffstat (limited to 'src')
| -rw-r--r-- | src/images.php | 18 |
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 |
