image-meta
v0.2.1
Published
Detect image type and size using pure javascript
Downloads
2,621,523
Readme
image-meta
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.