image-meta

Detect image type and size using pure javascript

MIT 6 个版本
安装
npm install image-meta
yarn add image-meta
pnpm add image-meta
bun add image-meta
README

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 the 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 💛

🔀 Based on image-size by Aditya Yadav and contributors.

Published under MIT License.

版本列表
0.2.2 2025-10-07
0.2.1 2024-07-03
0.2.0 2023-10-18
0.1.1 2021-10-27
0.0.1 2020-10-28
0.0.0 2020-10-28