Skip to content
On this page

Home > @taiyuuki/utils > image_get_type

image_get_type() function

该函数根据文件扩展名返回图像文件的 MIME 类型。

Signature:

typescript
declare function image_get_type(filename: string): "image/png" | "image/jpeg" | "image/gif" | "image/webp" | "image/bmp" | "image/svg+xml" | "image/x-icon" | "image/tiff";
declare function image_get_type(filename: string): "image/png" | "image/jpeg" | "image/gif" | "image/webp" | "image/bmp" | "image/svg+xml" | "image/x-icon" | "image/tiff";

Parameters

ParameterTypeDescription
filenamestring表示图像文件名称的字符串,包括其扩展名。

Returns:

"image/png" | "image/jpeg" | "image/gif" | "image/webp" | "image/bmp" | "image/svg+xml" | "image/x-icon" | "image/tiff"

基于文件扩展名的图像文件的 MIME 类型。如果无法识别文件扩展名,它将返回默认的 MIME 类型。

Released under the MIT License.