check-image-type
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

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;

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i check-image-type

    Weekly Downloads

    121

    Version

    0.1.4

    License

    MIT

    Unpacked Size

    77.1 kB

    Total Files

    12

    Last publish

    Collaborators

    • ahaoboy