@jongleberry/identify

1.0.0 • Public • Published

@jongleberry/identify

Node.js CI codecov

A tiny image identification service:

  • Uses libvips via sharp if available
  • Falls back to ImageMagick
  • Errors if neither exist

API

const IdentifyService = require('@jongleberry/identify')

const identifyService = new IdentifyService({
  // defaults, no need to set these
  sharp: true,
  imagemagick: true, 
})

const filename = 'some-image.png'

try {
  const result = await identifyService.identify(filename)
  // ['imagemagick', {}]
  // ['sharp', {}]

  const metadata = await identifyService.normalize(result)
  // { width, height, ... }
} catch (err) {
  if (identifyService.isNotAnImageError(err)) throw new Error(`${filename} is not an image.`)
  throw err
}

Package Sidebar

Install

npm i @jongleberry/identify

Weekly Downloads

52

Version

1.0.0

License

MIT

Unpacked Size

5.73 kB

Total Files

4

Last publish

Collaborators

  • jongleberry