Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Dec 14, 2012
0 parents commit 353ead3
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
support
test
examples
*.sock
5 changes: 5 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

0.0.1 / 2010-01-03
==================

* Initial release
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

test:
@./node_modules/.bin/mocha \
--require should \
--reporter spec

.PHONY: test
133 changes: 133 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@

# exif

EXIF extraction with exiftool.

### Example

```js
var exif = require('exif');

exif(file, function(err, obj){
console.log(obj);
})
```

```json
{
"exiftool version number": "9.08",
"file name": "forest.jpeg",
"directory": "test/fixtures",
"file size": "497 kB",
"file modification date time": "2012:12:11 14:45:59-08:00",
"file access date time": "2012:12:13 16:18:36-08:00",
"file inode change date time": "2012:12:11 14:45:59-08:00",
"file permissions": "rw-------",
"file type": "JPEG",
"mime type": "image/jpeg",
"jfif version": "1.01",
"exif byte order": "Big-endian (Motorola, MM)",
"photometric interpretation": "Color Filter Array",
"make": "NIKON CORPORATION",
"camera model name": "NIKON D7000",
"orientation": "Horizontal (normal)",
"x resolution": "72",
"y resolution": "72",
"resolution unit": "inches",
"software": "Pixelmator 2.1.1",
"modify date": "2012:10:08 19:10:63.50",
"exposure time": "1/80",
"f number": "5.6",
"exposure program": "Aperture-priority AE",
"iso": "500",
"date time original": "2012:10:07 11:36:30.50",
"create date": "2012:10:07 11:36:30.50",
"exposure compensation": "-2",
"max aperture value": "4.0",
"metering mode": "Multi-segment",
"light source": "Unknown",
"flash": "Off, Did not fire",
"focal length": "10.0 mm (35 mm equivalent: 15.0 mm)",
"sub sec time": "50",
"sub sec time original": "50",
"sub sec time digitized": "50",
"color space": "sRGB",
"exif image width": "1971",
"exif image height": "1306",
"sensing method": "One-chip color area",
"custom rendered": "Normal",
"exposure mode": "Auto",
"white balance": "Auto",
"digital zoom ratio": "1",
"focal length in 35mm format": "15 mm",
"scene capture type": "Standard",
"gain control": "Low gain up",
"contrast": "Normal",
"saturation": "Normal",
"sharpness": "Normal",
"subject distance range": "Unknown",
"profile cmm type": "Lino",
"profile version": "2.1.0",
"profile class": "Display Device Profile",
"color space data": "RGB",
"profile connection space": "XYZ",
"profile date time": "1998:02:09 06:49:00",
"profile file signature": "acsp",
"primary platform": "Microsoft Corporation",
"cmm flags": "Not Embedded, Independent",
"device manufacturer": "IEC",
"device model": "sRGB",
"device attributes": "Reflective, Glossy, Positive, Color",
"rendering intent": "Perceptual",
"connection space illuminant": "0.9642 1 0.82491",
"profile creator": "HP",
"profile id": "0",
"profile copyright": "Copyright (c) 1998 Hewlett-Packard Company",
"profile description": "sRGB IEC61966-2.1",
"media white point": "0.95045 1 1.08905",
"media black point": "0 0 0",
"red matrix column": "0.43607 0.22249 0.01392",
"green matrix column": "0.38515 0.71687 0.09708",
"blue matrix column": "0.14307 0.06061 0.7141",
"device mfg desc": "IEC http://www.iec.ch",
"device model desc": "IEC 61966-2.1 Default RGB colour space - sRGB",
"viewing cond desc": "Reference Viewing Condition in IEC61966-2.1",
"viewing cond illuminant": "19.6445 20.3718 16.8089",
"viewing cond surround": "3.92889 4.07439 3.36179",
"viewing cond illuminant type": "D50",
"luminance": "76.03647 80 87.12462",
"measurement observer": "CIE 1931",
"measurement backing": "0 0 0",
"measurement geometry": "Unknown (0)",
"measurement flare": "0.999%",
"measurement illuminant": "D65",
"technology": "Cathode Ray Tube Display",
"red tone reproduction curve": "(Binary data 2060 bytes, use -b option to extract)",
"green tone reproduction curve": "(Binary data 2060 bytes, use -b option to extract)",
"blue tone reproduction curve": "(Binary data 2060 bytes, use -b option to extract)",
"xmp toolkit": "XMP Core 4.4.0",
"serial number": "5044750",
"lens": "Sigma 10-20mm F4-5.6 EX DC HSM",
"image number": "6069",
"flash compensation": "0",
"image width": "900",
"image height": "596",
"encoding process": "Baseline DCT, Huffman coding",
"bits per sample": "8",
"color components": "3",
"y cb cr sub sampling": "YCbCr4:4:4 (1 1)",
"aperture": "5.6",
"image size": "900x596",
"scale factor to 35 mm equivalent": "1.5",
"shutter speed": "1/80",
"circle of confusion": "0.020 mm",
"field of view": "100.4 deg",
"hyperfocal distance": "0.89 m",
"lens id": "Unknown (809257734)",
"light value": "9.0"
}
```

## License

MIT
44 changes: 44 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

/**
* Module dependencies.
*/

var exec = require('child_process').exec
, command = require('shelly');

/**
* Fetch EXIF data from `file` and invoke `fn(err, data)`.
*
* @param {String} file
* @param {Function} fn
* @api public
*/

module.exports = function(file, fn){
var cmd = command('exiftool ?', file);
exec(cmd, function(err, str){
if (err) return fn(err);

var obj = str.split('\n').reduce(function(obj, line){
var i = line.indexOf(':');
var key = slug(line.slice(0, i));
var val = line.slice(i + 1, line.length).trim();
if ('' == key || '' == val) return obj;
obj[key] = val;
return obj;
}, {});

fn(null, obj);
});
};

/**
* Slug `str`.
*/

function slug(str) {
return str
.trim()
.replace(/[^\w]+/g, ' ')
.toLowerCase();
}
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "exif",
"version": "0.0.1",
"description": "EXIF extraction with exiftool",
"keywords": [],
"author": "TJ Holowaychuk <[email protected]>",
"dependencies": {
"shelly": "0.0.3"
},
"devDependencies": {
"mocha": "*",
"better-assert": "*"
},
"main": "index"
}
Binary file added test/fixtures/forest.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

var exif = require('..');
var assert = require('better-assert');

describe('exif(file, fn)', function(){
it('respond with EXIF json data', function(done){
exif('test/fixtures/forest.jpeg', function(err, o){
if (err) return done(err);
assert('forest.jpeg' == o['file name']);
done();
});
})
})

0 comments on commit 353ead3

Please sign in to comment.