check-image-type
v0.1.4
Published
Detect the image type of Buffer/Uint8Array
Downloads
290
Maintainers
Readme
fork from file-type
support image type:
WEBP,
JPG,
PNG,
GIF,
BMP,
AVIF,
HEIC,
BPG,
ICO,
PSD,
JXR,
FLIF,
ICNS,
ORF,
XCF,
RW2,
KTX,
JXL,
CUR,
RAF
only 4k gzipped:1.4k
install
npm install check-image-type
usage
import { checkImage, JPG, isJPG} from 'check-image-type'
const buffer = readFileSync("test.jpg");
expect(checkImage(buffer)).toEqual(JPG);
assert(isJPG(buffer))
type
export const WEBP = {
ext: "webp",
mime: "image/webp",
} as const;
export type WEBP_TYPE = typeof WEBP;
export const JPG = {
ext: "jpg",
mime: "image/jpeg",
} as const;
export type JPG_TYPE = typeof JPG;
export const PNG = {
ext: "png",
mime: "image/png",
} as const;
export type PNG_TYPE = typeof PNG;
export const BMP = {
ext: "bmp",
mime: "image/bmp",
} as const;
export type BMP_TYPE = typeof BMP;
export const GIF = {
ext: "gif",
mime: "image/gif",
} as const;
export type GIF_TYPE = typeof GIF;
export const AVIF = {
ext: "gif",
mime: "image/gif",
} as const;
export type AVIF_TYPE = typeof AVIF;
export const HEIC = {
ext: "gif",
mime: "image/gif",
} as const;
export type HEIC_TYPE = typeof HEIC;