这是一个简单的模块,用于根据图像的幻数检查图像的类型(无需加载整个图像)。 它目前适用于 JPEG、PNG、GIF、BMP 和 ICO。
注意:JPEG、PNG、GIF、BMP 和 ICO
ohpm install @nutpi/img-type
import { imagetype } from '@nutpi/img-type'
imagetype(pathToImage, (type?: string) => {
// type can take the following values:
// 'jpeg', 'png', 'gif', 'bmp', 'ico' or null if the type is not recognized
console.log('The image type is', type);
});
https://www.nutpi.net/