Skip to content

Commit ced3f2f

Browse files
committed
1 parent 1a2929f commit ced3f2f

32 files changed

+489
-4
lines changed

package.json

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
{
22
"name" : "exif",
3-
"version" : "0.5.1",
3+
"version" : "0.6.0",
44
"description" : "A node.js library to extract Exif metadata from images.",
5-
"author" : "Daniel Leinich <[email protected]>",
6-
"keywords" : ["exif", "image", "jpeg", "jpg", "tiff", "makernotes", "gps"],
5+
"author" : [ "Daniel Leinich <[email protected]>", "Olivier Oeuillot <[email protected]>" ],
6+
"keywords" : ["exif", "image", "jpeg", "jpg", "makernotes", "gps"],
77
"main" : "./lib/exif",
88
"repository" : {
99
"type" : "git",
1010
"url" : "http://github.com/gomfunkel/node-exif.git"
1111
},
1212
"dependencies": {
13-
"debug": "2.2"
13+
"debug": "^2.2"
14+
},
15+
"devDependencies": {
16+
"mocha": "^2.4"
17+
},
18+
"scripts": {
19+
"test": "node_modules/.bin/mocha --reporter spec test/*-test.js"
1420
}
1521
}

test/api-test.js

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
var assert = require('assert');
2+
var fs=require('fs');
3+
var Path = require('path');
4+
5+
describe('node-exif API', function() {
6+
7+
var path=Path.join(__dirname, "evil1.jpg");
8+
var json='{"image":{"Make":"Canon","Model":"Canon PowerShot S400","Orientation":1,"XResolution":180,"YResolution":180,"ResolutionUnit":2,"Software":"Adobe Photoshop 7.0","ModifyDate":"2003:05:25 11:11:41","YCbCrPositioning":1,"ExifOffset":217},"thumbnail":{"Compression":6,"XResolution":72,"YResolution":72,"ResolutionUnit":2,"ThumbnailOffset":1057,"ThumbnailLength":6298},"exif":{"ExposureTime":0.125,"FNumber":2.8,"ExifVersion":{"type":"Buffer","data":[48,50,50,48]},"DateTimeOriginal":"2003:05:24 16:40:33","CreateDate":"2003:05:24 16:40:33","ComponentsConfiguration":{"type":"Buffer","data":[1,2,3,0]},"CompressedBitsPerPixel":3,"ShutterSpeedValue":3,"ApertureValue":2.96875,"ExposureCompensation":0,"MaxApertureValue":2.96875,"MeteringMode":5,"Flash":16,"FocalLength":7.40625,"UserComment":{"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"FlashpixVersion":{"type":"Buffer","data":[48,49,48,48]},"ColorSpace":1,"ExifImageWidth":400,"ExifImageHeight":300,"FocalPlaneXResolution":8114.285714285715,"FocalPlaneYResolution":8114.285714285715,"FocalPlaneResolutionUnit":2,"SensingMethod":2,"FileSource":{"type":"Buffer","data":[3]},"CustomRendered":0,"ExposureMode":0,"WhiteBalance":0,"DigitalZoomRatio":1,"SceneCaptureType":0},"gps":{},"interoperability":{},"makernote":{}}';
9+
10+
11+
it('test constructor (filename)', function(done) {
12+
13+
var ExifImage = require('..').ExifImage;
14+
15+
new ExifImage({image: path }, function(error, data) {
16+
if (error) {
17+
throw error;
18+
}
19+
20+
assert.equal(JSON.stringify(data), json, "Not same datas ?");
21+
22+
done();
23+
});
24+
});
25+
26+
it('test constructor (buffer)', function(done) {
27+
28+
var ExifImage = require('..').ExifImage;
29+
30+
var buffer=fs.readFileSync(path);
31+
32+
new ExifImage({image: buffer }, function(error, data) {
33+
if (error) {
34+
throw error;
35+
}
36+
37+
assert.equal(JSON.stringify(data), json, "Not same datas ?");
38+
39+
done();
40+
});
41+
});
42+
43+
it('test loadImage (buffer)', function(done) {
44+
45+
var ExifImage = require('..').ExifImage;
46+
47+
var exif=new ExifImage();
48+
49+
exif.loadImage(path, function(error, data) {
50+
if (error) {
51+
throw error;
52+
}
53+
54+
assert.equal(JSON.stringify(data), json, "Not same datas ?");
55+
56+
done();
57+
});
58+
});
59+
60+
it('test loadImage (filename)', function(done) {
61+
62+
var ExifImage = require('..').ExifImage;
63+
64+
var buffer=fs.readFileSync(path);
65+
66+
var exif=new ExifImage();
67+
68+
exif.loadImage(buffer , function(error, data) {
69+
if (error) {
70+
throw error;
71+
}
72+
73+
assert.equal(JSON.stringify(data), json, "Not same datas");
74+
75+
done();
76+
});
77+
});
78+
79+
it('test wrapper', function(done) {
80+
81+
var Exif = require('..');
82+
83+
Exif(path, function(error, data, dataPath) {
84+
if (error) {
85+
throw error;
86+
}
87+
88+
assert.equal(dataPath, path, "Not same path");
89+
delete data.path;
90+
91+
assert.equal(JSON.stringify(data), json, "Not same datas ?");
92+
93+
done();
94+
});
95+
});
96+
});
97+
98+
describe('node-exif tests', function() {
99+
var ExifImage = require('..').ExifImage;
100+
101+
var files=fs.readdirSync(__dirname);
102+
103+
files.forEach(function(f) {
104+
if (!/\.jpg$/.exec(f)) {
105+
return;
106+
}
107+
108+
var path=Path.join(__dirname, f);
109+
110+
it('test '+f, function(done) {
111+
var expected=String(fs.readFileSync(path+".json"));
112+
113+
new ExifImage({image: path }, function(error, data) {
114+
if (error) {
115+
throw error;
116+
}
117+
118+
var json=JSON.stringify(data);
119+
120+
//console.log(" data=", json, json.length);
121+
// console.log("expected=", expected, expected.length);
122+
123+
assert.equal(json, expected, "Data are not the same");
124+
125+
done();
126+
});
127+
});
128+
});
129+
});

test/down-mirrored.jpg

15.1 KB
Loading

test/down-mirrored.jpg.expected

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Camera make :
2+
Camera model :
3+
Software :
4+
Bits per sample : 0
5+
Image width : 0
6+
Image height : 0
7+
Image description :
8+
Image orientation : 4
9+
Image copyright :
10+
Image date/time :
11+
Original date/time :
12+
Digitize date/time :
13+
Subsecond time :
14+
Exposure time : 1/0 s
15+
F-stop : f/0.0
16+
ISO speed : 0
17+
Subject distance : 0.000000 m
18+
Exposure bias : 0.000000 EV
19+
Flash used? : 0
20+
Metering mode : 0
21+
Lens focal length : 0.000000 mm
22+
35mm focal length : 0 mm
23+
GPS Latitude : 0.000000 deg (0.000000 deg, 0.000000 min, 0.000000 sec ?)
24+
GPS Longitude : 0.000000 deg (0.000000 deg, 0.000000 min, 0.000000 sec ?)
25+
GPS Altitude : 0.000000 m
26+
GPS Precision (DOP) : 0.000000
27+
Lens min focal length: 0.000000 mm
28+
Lens max focal length: 0.000000 mm
29+
Lens f-stop min : f/0.0
30+
Lens f-stop max : f/0.0
31+
Lens make :
32+
Lens model :
33+
Focal plane XRes : 0.000000
34+
Focal plane YRes : 0.000000

test/down-mirrored.jpg.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"image":{"Orientation":4,"XResolution":28,"YResolution":28,"ResolutionUnit":3,"YCbCrPositioning":1},"thumbnail":{},"exif":{},"gps":{},"interoperability":{},"makernote":{}}

test/evil1.jpg

84.5 KB
Loading

test/evil1.jpg.expected

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Camera make : Canon
2+
Camera model : Canon PowerShot S400
3+
Software : Adobe Photoshop 7.0
4+
Bits per sample : 0
5+
Image width : 400
6+
Image height : 300
7+
Image description :
8+
Image orientation : 1
9+
Image copyright :
10+
Image date/time : 2003:05:25 11:11:41
11+
Original date/time : 2003:05:24 16:40:33
12+
Digitize date/time : 2003:05:24 16:40:33
13+
Subsecond time :
14+
Exposure time : 1/8 s
15+
F-stop : f/2.8
16+
ISO speed : 0
17+
Subject distance : 0.000000 m
18+
Exposure bias : 0.000000 EV
19+
Flash used? : 1
20+
Metering mode : 5
21+
Lens focal length : 7.406250 mm
22+
35mm focal length : 0 mm
23+
GPS Latitude : 0.000000 deg (0.000000 deg, 0.000000 min, 0.000000 sec ?)
24+
GPS Longitude : 0.000000 deg (0.000000 deg, 0.000000 min, 0.000000 sec ?)
25+
GPS Altitude : 0.000000 m
26+
GPS Precision (DOP) : 0.000000
27+
Lens min focal length: 0.000000 mm
28+
Lens max focal length: 0.000000 mm
29+
Lens f-stop min : f/0.0
30+
Lens f-stop max : f/0.0
31+
Lens make :
32+
Lens model :
33+
Focal plane XRes : 8114.285714
34+
Focal plane YRes : 8114.285714

test/evil1.jpg.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"image":{"Make":"Canon","Model":"Canon PowerShot S400","Orientation":1,"XResolution":180,"YResolution":180,"ResolutionUnit":2,"Software":"Adobe Photoshop 7.0","ModifyDate":"2003:05:25 11:11:41","YCbCrPositioning":1,"ExifOffset":217},"thumbnail":{"Compression":6,"XResolution":72,"YResolution":72,"ResolutionUnit":2,"ThumbnailOffset":1057,"ThumbnailLength":6298},"exif":{"ExposureTime":0.125,"FNumber":2.8,"ExifVersion":{"type":"Buffer","data":[48,50,50,48]},"DateTimeOriginal":"2003:05:24 16:40:33","CreateDate":"2003:05:24 16:40:33","ComponentsConfiguration":{"type":"Buffer","data":[1,2,3,0]},"CompressedBitsPerPixel":3,"ShutterSpeedValue":3,"ApertureValue":2.96875,"ExposureCompensation":0,"MaxApertureValue":2.96875,"MeteringMode":5,"Flash":16,"FocalLength":7.40625,"UserComment":{"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"FlashpixVersion":{"type":"Buffer","data":[48,49,48,48]},"ColorSpace":1,"ExifImageWidth":400,"ExifImageHeight":300,"FocalPlaneXResolution":8114.285714285715,"FocalPlaneYResolution":8114.285714285715,"FocalPlaneResolutionUnit":2,"SensingMethod":2,"FileSource":{"type":"Buffer","data":[3]},"CustomRendered":0,"ExposureMode":0,"WhiteBalance":0,"DigitalZoomRatio":1,"SceneCaptureType":0},"gps":{},"interoperability":{},"makernote":{}}

test/lens_info.jpg

897 Bytes
Loading

test/lens_info.jpg.expected

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Camera make :
2+
Camera model :
3+
Software :
4+
Bits per sample : 0
5+
Image width : 0
6+
Image height : 0
7+
Image description :
8+
Image orientation : 0
9+
Image copyright :
10+
Image date/time :
11+
Original date/time :
12+
Digitize date/time :
13+
Subsecond time :
14+
Exposure time : 1/0 s
15+
F-stop : f/0.0
16+
ISO speed : 0
17+
Subject distance : 0.000000 m
18+
Exposure bias : 0.000000 EV
19+
Flash used? : 0
20+
Metering mode : 0
21+
Lens focal length : 0.000000 mm
22+
35mm focal length : 0 mm
23+
GPS Latitude : 0.000000 deg (0.000000 deg, 0.000000 min, 0.000000 sec ?)
24+
GPS Longitude : 0.000000 deg (0.000000 deg, 0.000000 min, 0.000000 sec ?)
25+
GPS Altitude : 0.000000 m
26+
GPS Precision (DOP) : 0.000000
27+
Lens min focal length: 10.000000 mm
28+
Lens max focal length: 400.000000 mm
29+
Lens f-stop min : f/1.1
30+
Lens f-stop max : f/1.2
31+
Lens make : Lens Maker Inc.
32+
Lens model : Lens Model mk I
33+
Focal plane XRes : 0.000000
34+
Focal plane YRes : 0.000000

test/lens_info.jpg.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"image":{"XResolution":96,"YResolution":96,"ResolutionUnit":2,"YCbCrPositioning":1,"ExifOffset":90},"thumbnail":{},"exif":{"ExifVersion":{"type":"Buffer","data":[48,50,51,48]},"ComponentsConfiguration":{"type":"Buffer","data":[1,2,3,0]},"FlashpixVersion":{"type":"Buffer","data":[48,49,48,48]},"ColorSpace":65535,"LensInfo":[10,400,1.1,1.2],"LensMake":"Lens Maker Inc.","LensModel":"Lens Model mk I","LensSerialNumber":"123"},"gps":{},"interoperability":{},"makernote":{}}

test/right.jpg

5.85 KB
Loading

test/right.jpg.expected

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Camera make :
2+
Camera model :
3+
Software :
4+
Bits per sample : 0
5+
Image width : 0
6+
Image height : 0
7+
Image description :
8+
Image orientation : 8
9+
Image copyright :
10+
Image date/time :
11+
Original date/time :
12+
Digitize date/time :
13+
Subsecond time :
14+
Exposure time : 1/0 s
15+
F-stop : f/0.0
16+
ISO speed : 0
17+
Subject distance : 0.000000 m
18+
Exposure bias : 0.000000 EV
19+
Flash used? : 0
20+
Metering mode : 0
21+
Lens focal length : 0.000000 mm
22+
35mm focal length : 0 mm
23+
GPS Latitude : 0.000000 deg (0.000000 deg, 0.000000 min, 0.000000 sec ?)
24+
GPS Longitude : 0.000000 deg (0.000000 deg, 0.000000 min, 0.000000 sec ?)
25+
GPS Altitude : 0.000000 m
26+
GPS Precision (DOP) : 0.000000
27+
Lens min focal length: 0.000000 mm
28+
Lens max focal length: 0.000000 mm
29+
Lens f-stop min : f/0.0
30+
Lens f-stop max : f/0.0
31+
Lens make :
32+
Lens model :
33+
Focal plane XRes : 0.000000
34+
Focal plane YRes : 0.000000

test/right.jpg.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"image":{"Orientation":8,"XResolution":28,"YResolution":28,"ResolutionUnit":3,"YCbCrPositioning":1},"thumbnail":{},"exif":{},"gps":{},"interoperability":{},"makernote":{}}

test/short-ascii-II.jpg

872 KB
Loading

test/short-ascii-II.jpg.expected

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Camera make : XIAOMI
2+
Camera model : MI3
3+
Software :
4+
Bits per sample : 0
5+
Image width : 4208
6+
Image height : 3120
7+
Image description :
8+
Image orientation : 1
9+
Image copyright :
10+
Image date/time : 2015:02:28 17:10:49
11+
Original date/time : 2015:02:28 17:10:49
12+
Digitize date/time : 2015:02:28 17:10:49
13+
Subsecond time :
14+
Exposure time : 1/20 s
15+
F-stop : f/2.2
16+
ISO speed : 250
17+
Subject distance : 0.000000 m
18+
Exposure bias : 0.000000 EV
19+
Flash used? : 1
20+
Metering mode : 2
21+
Lens focal length : 3.510000 mm
22+
35mm focal length : 0 mm
23+
GPS Latitude : 0.000000 deg (0.000000 deg, 0.000000 min, 0.000000 sec ?)
24+
GPS Longitude : 0.000000 deg (0.000000 deg, 0.000000 min, 0.000000 sec ?)
25+
GPS Altitude : 0.000000 m
26+
GPS Precision (DOP) : 0.000000
27+
Lens min focal length: 0.000000 mm
28+
Lens max focal length: 0.000000 mm
29+
Lens f-stop min : f/0.0
30+
Lens f-stop max : f/0.0
31+
Lens make :
32+
Lens model :
33+
Focal plane XRes : 0.000000
34+
Focal plane YRes : 0.000000

0 commit comments

Comments
 (0)