Permalink
Browse files

identify result includes EXIF:Orientation attribute

  • Loading branch information...
1 parent 3abcbd6 commit 5a46631b109477730d7a36e31811406c3d763718 @mash mash committed Jan 31, 2014
Showing with 14 additions and 6 deletions.
  1. +4 −1 README.markdown
  2. +4 −0 src/imagemagick.cc
  3. +6 −5 test/test.js
View
@@ -61,7 +61,10 @@ The method returns an object similar to:
format: 'JPEG',
width: 3904,
height: 2622,
- depth: 8
+ depth: 8,
+ exif: {
+ orientation: 0 # 0 if none exists
+ }
}
### quantizeColors( options )
View
@@ -300,6 +300,10 @@ Handle<Value> Identify(const Arguments& args) {
out->Set(String::NewSymbol("depth"), Integer::New(image.depth()));
out->Set(String::NewSymbol("format"), String::New(image.magick().c_str()));
+ Handle<Object> out_exif = Object::New();
+ out_exif->Set(String::NewSymbol("orientation"), Integer::New(atoi(image.attribute("EXIF:Orientation").c_str())));
+ out->Set(String::NewSymbol("exif"), out_exif);
+
return scope.Close( out );
}
View
@@ -244,13 +244,14 @@ test( 'identify srcData is a Buffer', function (t) {
});
test( 'identify results', function (t) {
- var results = imagemagick.identify({
+ var info = imagemagick.identify({
srcData: require('fs').readFileSync( "./test/test.png" )
});
- t.equal( results.width, 58, 'width is 58' );
- t.equal( results.height, 66, 'height is 66' );
- t.equal( results.depth, 8, 'depth is 8' );
- t.equal( results.format, 'PNG', 'format is PNG' );
+ t.equal( info.width, 58, 'width is 58' );
+ t.equal( info.height, 66, 'height is 66' );
+ t.equal( info.depth, 8, 'depth is 8' );
+ t.equal( info.format, 'PNG', 'format is PNG' );
+ t.equal( info.exif.orientation, 0, 'orientation doesnt exist' );
t.end();
});

0 comments on commit 5a46631

Please sign in to comment.