From 5a46631b109477730d7a36e31811406c3d763718 Mon Sep 17 00:00:00 2001 From: Masakazu OHTSUKA Date: Fri, 31 Jan 2014 12:25:25 +0900 Subject: [PATCH] identify result includes EXIF:Orientation attribute https://github.com/mash/node-imagemagick-native/issues/15 --- README.markdown | 5 ++++- src/imagemagick.cc | 4 ++++ test/test.js | 11 ++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.markdown b/README.markdown index 9d4c969..48fa73c 100644 --- a/README.markdown +++ b/README.markdown @@ -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 ) diff --git a/src/imagemagick.cc b/src/imagemagick.cc index c2b72ee..e04ca35 100644 --- a/src/imagemagick.cc +++ b/src/imagemagick.cc @@ -300,6 +300,10 @@ Handle 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 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 ); } diff --git a/test/test.js b/test/test.js index af4befc..bc41ef8 100644 --- a/test/test.js +++ b/test/test.js @@ -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(); });