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

0.2.0 • Public • Published

image-meta

npm version npm downloads bundle Codecov

Detect image type and size using pure javascript.

Usage

Install package:

# npm
npm install image-meta

# yarn
yarn add image-meta

# pnpm
pnpm install image-meta

# bun
bun install image-meta
import { imageMeta } from "image-meta";

const data = await fetch(url).then((res) => res.buffer());

// Meta contains { type, width?, height?, orientation? }
const meta = imageMeta(data);

Note: imageMeta throws an error if either data is not a Buffer/Uint8Array, or data is invalid or type cannot be determined. You should wrap it into a try/catch statement to handle errors.

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Made with 💛

Published under MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i image-meta

Weekly Downloads

500,216

Version

0.2.0

License

MIT

Unpacked Size

42.7 kB

Total Files

8

Last publish

Collaborators

  • pi0