Skip to content

mattburns/exiftool.js

Repository files navigation

exiftool.js

A pure javascript implementation of Phil Harvey's excellent exiftool. This extends work started by Jacob Seidelin and aims to support parsing of all the tags that exiftool is capable of. Currently only jpeg is supported.

See how well we're doing in the latest Coverage report

The current javascript implementation conforms to the ECMAScript 5.1 which should work in older node.js versions.

Usage

With jQuery:

$(this).getExifFromUrl(url, function(exif) {
    console.log("Make is : " + exif["Make"]);
});

Or you can read from a local file (like drag and drop):

var binaryReader = new FileReader();
binaryReader.onloadend = function() {
    var exif = $(this).findEXIFinJPEG(binaryReader.result);
    console.log("Make is : " + exif["Make"]);
}
binaryReader.readAsBinaryString(file);

Or using node.js (exiftool.js is packaged on npm here):

var exiftool = require('exiftool.js');
var fs = require('fs');

exiftool.getExifFromLocalFileUsingNodeFs(fs, imgFile, function(err, exif) {
    console.log("Make is : " + exif["Make"]);
});

Or for node.js if the image is already in a Buffer:

var exiftool = require('exiftool.js');

exiftool.getExifFromNodeBuffer(buffer, function(err, exif) {
    console.log("Make is : " + exif["Make"]);
});

Coverage

You can view exactly how the results from this library fair verses the perl library against images from 6,000 different camera models here: Coverage report

I see no reason why this library can't match (and exceed!) the parsing capabilities of the orginal perl library but I need your help. Please fork this repo, create pull request and issue, whatever. You can just play with making improvements to the code so that the coverage goes up.

Note that all the test files used to be in this repo which means the history is really big. Avoid a large checkout using a depth of 1. The test files are now kept in a submodule, so you'll need the recursive option.

git clone --depth 1 --recursive https://github.com/mattburns/exiftool.js.git

It's easy to see how much your changes are improving this thanks to the coverage report above. To regenerate this simply run:

npm install
npm test

This will thrash every sample image through exiftool.js, and variants of node-exif then generate the report files to compare the output.

Alternatively, there's a slower version for the paranoid:

npm install
env exiftoolclean=true npm test

This will do the same thing, but also ensure the json output files generated from the perl exiftool are up to date.

Because we use a submodule, diff your changes using:

git diff && git submodule foreach 'git diff'

And push using:

git push --recurse-submodules=on-demand

Adding more images

If you want to test some of your own image files, copy them into the sampleImages/_Other directory. Then, if you want to check them in, I have a script (c/o Phil Harvey) that will swap the main image with a small blank white square. This keeps the files small but don't rely on it giving you full anonymity because there may still be thumbnail image data in the file or other personal info in the filesname or other exif tags.

The script is called swap_image.pl but to keep things complicated, I suggest you just run the ant script:

ant

Releases and automated changelog

We use the generate-changelog tool when releasing new versions. This gives us the following goodies:

  • automated CHANGELOG generation
  • automated package version numbering (in package.json)
  • new git tag for each release

In order to do that, commit messages that should appear in the changelog should follow simple formatting rules type(optional): message (see the generate-changelog for further info)

Example:

fix(issue #36): duplicate declaration in EXIF.TiffTags 0x0132

NOTE: Make sure, your git remote is named 'origin' because our script expects it.

How to use from CLI

# run this to release a new patch version (e.g. 0.3.2 -> 0.3.3)
yarn release:patch

# run this to release a new minor version (e.g. 0.3.2 -> 0.4.0)
yarn release:minor

# run this to release a new major version (e.g. 0.3.2 -> 1.0.0)
yarn release:major

About

A pure javascript implementation of exiftool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •