Retrieve image metadata as a JSON object using ImageMagick's identify
command.
- Node.JS v0.10 or newer
- ImageMagick v6.8 or newer
npm install im-metadata --save
var metadata = require('im-metadata');
Return metadata object for a given src
image.
- string
src
- path to the image on disk - object
opts
- metadata parsing options- boolean
exif
- return exif data or not (defaultfalse
) - boolean
autoOrient
- auto-orient height/width (defaultfalse
) - integer
timeout
- command timeout length (default5000
)
- boolean
- function
callback
- callback function (Errorerror
, objectdata
)- Error
error
- error output if command failed - object
data
- parsed metadata object
- Error
Returns an object
with parsed metada:
- string
path
- original image path - string
name
- original image name - string
size
- image file size in bytes (ex.4504682
) - string
format
- image format (JPEG
,PNG
,TIFF
etc.) - string
colorspace
- image colorspace (RGB
,CMYK
etc.) - integer
height
- image pixel height - integer
width
- image pixel width - string
orientation
- image orientation
metadata('/path/to/image.jpg', {exif: true}, function(error, metadata) {
if (error) { console.error(error); }
console.log(metadata);
console.log(metadata.exif);
});