3

I'm writing a nodeJS 5.3.0 application using gm (http://aheckmann.github.io/gm/)

I know that it uses the GraphicsMagicK library.

the problem is that I'm having is that after I resize an image, it loses it's exif format. the code samples actually shows that the exif format is lost.

for example:

var fs = require('fs')
  , gm = require('gm').subClass({imageMagick: true});

// resize and remove EXIF profile data
gm('/path/to/my/img.jpg')
.resize(240, 240)

in this example they say that exif profile data is removed.

I know that I can get the orientation of an image before resizing using:

gm('path/tp/my/img.jpg').orientation(function(err,value){
                var orientation = value;
});

the question is.. can I preserve exif data when resizing ? and If not.. can I set exif orientation data after resizing ?

thanks

ufk
  • 30,912
  • 70
  • 235
  • 386
  • 1
    I just tried with GraphicsMagick installed and the EXIF profile is keeped in the resized image. Maybe it's a bug with ImageMagick? – Shanoor Jan 03 '16 at 20:10
  • can you use https://www.npmjs.com/package/piexifjs to read exif data and write to the resized image? – YarGnawh Jan 03 '16 at 23:25
  • @ShanShan - it seems you are right, I tested it on my work computer with GraphicsMagicK and it does save exif format. when I get home later today I'll check what's the difference – ufk Jan 04 '16 at 11:03

1 Answers1

3

More specifically in the following code, only noProfile() function remove EXIF, so if you remove it you can preserve EXIF data

 // resize and remove EXIF profile data
gm('/path/to/my/img.jpg')
   .resize(240, 240)
   .noProfile()
   .write('/path/to/resize.png', function (err) {
   if (!err) console.log('done');
});

Otherwise you can check the gm doc here

Tovo
  • 149
  • 2