A node.js library to extract Exif metadata from images.
npm install exifWith _node-exif_ you can extract Exif metadata from images (JPEG). Exif is a format used, for example, by digital cameras and scanners to save additional information about an image in the image file. This information can be the camera model, resolution, where the image was taken (GPS) or when it was taken.
Rodrigo Espinosa proposes the npm package exif-cli to execute node-exif from a shell.
* Installation
* Usage
* ToDo / Ideas
* License
Installing using npm (node package manager):
npm install exif
If you don't have npm installed or don't want to use it:
cd ~/.node_libraries
git clone git://github.com/gomfunkel/node-exif.git exif
Easy. Just require _node-exif_ and throw an image at it. If _node-exif_ is able to extract data from the image it does so and returns an object with all the information found, if an error occurs you will receive an error message. To prove that it really is easy please see the following example.
``javascript
var ExifImage = require('exif').ExifImage;
try {
new ExifImage({ image : 'myImage.jpg' }, function (error, exifData) {
if (error)
console.log('Error: '+error.message);
else
console.log(exifData); // Do something with your data!
});
} catch (error) {
console.log('Error: ' + error.message);
}
`
Instead of providing a filename of an image in your filesystem you can also pass a Buffer to ExifImage.
The data returned (exifData in the example above) is an object containing objects for each type of available Exif metadata:
* image for image information data (IFD0)thumbnail
* for information regarding a possibly embedded thumbnail (IFD1)exif
* for Exif-specific attribute information (Exif IFD)gps
* for GPS information (GPS IFD)interoperability
* for interoperability information (Interoperability IFD)makernote
* for vendor specific Exif information (Makernotes)
The ouput for an example image might thus look like this:
```
{
image: {
Make: 'FUJIFILM',
Model: 'FinePix40i',
Orientation: 1,
XResolution: 72,
YResolution: 72,
ResolutionUnit: 2,
Software: 'Digital Camera FinePix40i Ver1.39',
ModifyDate: '2000:08:04 18:22:57',
YCbCrPositioning: 2,
Copyright: ' ',
ExifOffset: 250
},
thumbnail: {
Compression: 6,
Orientation: 1,
XResolution: 72,
YResolution: 72,
ResolutionUnit: 2,
ThumbnailOffset: 1074,
ThumbnailLength: 8691,
YCbCrPositioning: 2
},
exif: {
FNumber: 2.8,
ExposureProgram: 2,
ISO: 200,
ExifVersion:
DateTimeOriginal: '2000:08:04 18:22:57',
CreateDate: '2000:08:04 18:22:57',
ComponentsConfiguration:
CompressedBitsPerPixel: 1.5,
ShutterSpeedValue: 5.5,
ApertureValue: 3,
BrightnessValue: 0.26,
ExposureCompensation: 0,
MaxApertureValue: 3,
MeteringMode: 5,
Flash: 1,
FocalLength: 8.7,
MakerNote:
FlashpixVersion:
ColorSpace: 1,
ExifImageWidth: 2400,
ExifImageHeight: 1800,
InteropOffset: 926,
FocalPlaneXResolution: 2381,
FocalPlaneYResolution: 2381,
FocalPlaneResolutionUnit: 3,
SensingMethod: 2,
FileSource:
SceneType:
},
gps: {},
interoperability: {
InteropIndex: 'R98',
InteropVersion:
},
makernote: {
Version:
Quality: 'NORMAL ',
Sharpness: 3,
WhiteBalance: 0,
FujiFlashMode: 1,
FlashExposureComp: 0,
Macro: 0,
FocusMode: 0,
SlowSync: 0,
AutoBracketing: 0,
BlurWarning: 0,
FocusWarning: 0,
ExposureWarning: 0
}
}
For more information about the Exif standard please refer to the specification found on http://www.exif.org. A comprehensive list of available Exif attributes and their meaning can be found on http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/.
There are a lot of things still to be done and to be made better. If you have any special requests please open an issue with a feature request.
_node-exif_ is licensed under the MIT License. (See LICENSE)