Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

check-image-type

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-image-type

Detect the image type of Buffer/Uint8Array

latest
npmnpm
Version
0.1.4
Version published
Maintainers
1
Created
Source

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;

Keywords

image type

FAQs

Package last updated on 28 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts