Skip to content

Commit

Permalink
identify result includes EXIF:Orientation attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mash committed Jan 31, 2014
1 parent 3abcbd6 commit 5a46631
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.markdown
Expand Up @@ -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 )
Expand Down
4 changes: 4 additions & 0 deletions src/imagemagick.cc
Expand Up @@ -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 );
}

Expand Down
11 changes: 6 additions & 5 deletions test/test.js
Expand Up @@ -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();
});

Expand Down

0 comments on commit 5a46631

Please sign in to comment.