Socket
Socket
Sign inDemoInstall

image-meta

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-meta - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

dist/index.d.cts

17

dist/index.d.ts

@@ -1,2 +0,3 @@

interface ISize {
type ImageMeta = {
images?: Omit<ImageMeta, "images">[];
width: number | undefined;

@@ -6,14 +7,10 @@ height: number | undefined;

type?: string;
mimeType?: string;
}
interface ISizeCalculationResult extends ISize {
images?: ISize[];
}
};
/**
* @param {Buffer|string} input - buffer of image data
* @param {Uint8Array|string} input - Uint8Array or relative/absolute path of the image file
* @param {Function=} [callback] - optional function for async detection
*/
declare function imageMeta(input: Buffer): ISizeCalculationResult | void;
declare const types: string[];
declare function imageMeta(input: Uint8Array): ImageMeta;
export { imageMeta, types };
export { type ImageMeta, imageMeta };
{
"name": "image-meta",
"version": "0.1.1",
"description": "",
"repository": "nuxt-contrib/image-meta",
"version": "0.2.0",
"description": "Detect image type and size using pure javascript",
"repository": "unjs/image-meta",
"license": "MIT",
"main": "dist/index.cjs",
"types": "dist/index.d.ts",
"sideEffects": false,
"type": "module",
"exports": {
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [

@@ -17,17 +23,25 @@ "dist"

"scripts": {
"lint": "eslint --ext .ts,.js .",
"prepack": "unbuild",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint"
"build": "unbuild",
"dev": "vitest dev",
"play": "jiti playground",
"lint": "eslint --cache --ext .ts,.js,.mjs,.cjs . && prettier -c src test",
"lint:fix": "eslint --cache --ext .ts,.js,.mjs,.cjs . --fix && prettier -c src test -w",
"prepack": "pnpm run build",
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
"test:types": "tsc --noEmit --skipLibCheck"
},
"devDependencies": {
"@nuxtjs/eslint-config-typescript": "latest",
"eslint": "latest",
"unbuild": "latest",
"standard-version": "latest",
"typescript": "latest"
"@types/node": "^20.8.6",
"@vitest/coverage-v8": "^0.34.6",
"changelogen": "^0.5.5",
"eslint": "^8.51.0",
"eslint-config-unjs": "^0.2.1",
"jiti": "^1.20.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2",
"unbuild": "^2.0.0",
"vitest": "^0.34.6"
},
"engines": {
"node": ">=10.18.0"
}
"packageManager": "pnpm@8.9.2"
}
# image-meta
[![npm version][npm-v-src]][npm-v-href]
[![npm downloads][npm-d-src]][npm-d-href]
[![bundle phobia][bundlephobia-src]][bundlephobia-href]
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![Codecov][codecov-src]][codecov-href]
Detect image type and size using pure javascript.
Using yarn:
## Usage
```
Install package:
```sh
# npm
npm install image-meta
# yarn
yarn add image-meta
```
Using npm:
# pnpm
pnpm install image-meta
# bun
bun install image-meta
```
npm install image-meta
```
Usage:
```ts
import { imageMeta } from 'image-meta'
import fetch from 'node-fetch'
import { imageMeta } from "image-meta";
const data = await fetch(url).then(res => res.buffer())
const { width, height, mimeType } = await imageMeta(data)
const data = await fetch(url).then((res) => res.buffer());
// Meta contains { type, width?, height?, orientation? }
const meta = imageMeta(data);
```
**Note:** This package only works with Node.js because of `Buffer` dependency!
**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](https://nodejs.org/en/)
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
- Install dependencies using `pnpm install`
- Run interactive tests using `pnpm dev`
## License
[MIT](./LICENSE) - Based on [image-size](https://github.com/image-size/image-size)
Made with 💛
<!-- Refs -->
[npm-v-src]: https://img.shields.io/npm/v/image-meta?style=flat-square
[npm-v-href]: https://npmjs.com/package/image-meta
Published under [MIT License](./LICENSE).
[npm-d-src]: https://img.shields.io/npm/dm/image-meta?style=flat-square
[npm-d-href]: https://npmjs.com/package/image-meta
<!-- Badges -->
[github-actions-src]: https://img.shields.io/github/workflow/status/nuxt-contrib/image-meta/ci/master?style=flat-square
[github-actions-href]: https://github.com/nuxt-contrib/image-meta/actions?query=workflow%3Aci
[bundlephobia-src]: https://img.shields.io/bundlephobia/min/image-meta?style=flat-square
[bundlephobia-href]: https://bundlephobia.com/result?p=image-meta
[npm-version-src]: https://img.shields.io/npm/v/image-meta?style=flat&colorA=18181B&colorB=F0DB4F
[npm-version-href]: https://npmjs.com/package/image-meta
[npm-downloads-src]: https://img.shields.io/npm/dm/image-meta?style=flat&colorA=18181B&colorB=F0DB4F
[npm-downloads-href]: https://npmjs.com/package/image-meta
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/image-meta/main?style=flat&colorA=18181B&colorB=F0DB4F
[codecov-href]: https://codecov.io/gh/unjs/image-meta
[bundle-src]: https://img.shields.io/bundlephobia/minzip/image-meta?style=flat&colorA=18181B&colorB=F0DB4F
[bundle-href]: https://bundlephobia.com/result?p=image-meta

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc