Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 984 Bytes

README.md

File metadata and controls

47 lines (33 loc) · 984 Bytes

mime-tree

👋 Intro

A helper for quickly determining the file type of a buffer.

This library is pure JavaScript, any can run in Node, the browser, or anywhere else JavaScript runs. This library is exported in CommonJS and ES Modules.

Compared to other libraries that iterate through multiple arrays to find the mime type, this helper detects mime type by looping through a single object.

Supported File Types

  • JPEG
  • PNG
  • GIF
  • WEBP
  • BMP
  • TIFF
  • AVIF

🚀 How to use

Install

To install this library, use on of the following commands:

npm install -S mime-tree
yarn add mime-tree

Use

import mimeFromBuffer from "mime-tree";

const image: Uint8Array = ...;

const mimeType = mimeFromBuffer(image);