https://github.com/jonathanong/identify
Image identification service with Vips via Sharp support falling back to ImageMagick
https://github.com/jonathanong/identify
imagemagick libvips vips
Last synced: 4 months ago
JSON representation
Image identification service with Vips via Sharp support falling back to ImageMagick
- Host: GitHub
- URL: https://github.com/jonathanong/identify
- Owner: jonathanong
- License: mit
- Created: 2020-11-29T10:48:47.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-16T16:10:37.000Z (almost 2 years ago)
- Last Synced: 2025-04-22T07:16:51.549Z (about 1 year ago)
- Topics: imagemagick, libvips, vips
- Language: JavaScript
- Homepage:
- Size: 187 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @jongleberry/identify
[](https://github.com/jonathanong/identify/actions?query=workflow%3A%22Node.js+CI%22+branch%3Amaster+event%3Apush)
[](https://codecov.io/gh/jonathanong/identify)
A tiny image identification service:
- Uses `libvips` via `sharp` if available
- Falls back to ImageMagick
- Errors if neither exist
## API
```js
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
}
```