X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FImages.php;h=077509d3cb5e6e1c64105e2a7886bd131cf31be5;hb=720a43461d67ab229de0aecfc5008f22cc4c1c54;hp=cd4704dcee068018ec0f1a4c4b8a701930e257f6;hpb=322b7c856ca9ba53bd9c7da50dd5c1e3c9197d56;p=friendica.git diff --git a/src/Util/Images.php b/src/Util/Images.php index cd4704dcee..077509d3cb 100644 --- a/src/Util/Images.php +++ b/src/Util/Images.php @@ -46,6 +46,30 @@ class Images return $m; } + /** + * Return file extension for mime type + * @param string $mimetype + * @return string + */ + public static function getExtensionByMimeType(string $mimetype): string + { + switch ($mimetype) { + case 'image/png': + $imagetype = IMAGETYPE_PNG; + break; + + case 'image/gif': + $imagetype = IMAGETYPE_GIF; + break; + + default: + $imagetype = IMAGETYPE_JPEG; + break; + } + + return image_type_to_extension($imagetype); + } + /** * Returns supported image mimetypes and corresponding file extensions *