![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | dist/ | 8 months ago | - | |
![]() | LICENSE | 8 months ago | 1.2K | |
![]() | README.md | 8 months ago | 1.8K | |
![]() | package.json | 8 months ago | 1.3K |
Detect image type and size using pure javascript.
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.
corepack enable
pnpm install
pnpm dev
Made with 💛
Published under MIT License.