Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read EXIF data? #365

Open
viki53 opened this issue Feb 23, 2015 · 3 comments
Open

Read EXIF data? #365

viki53 opened this issue Feb 23, 2015 · 3 comments

Comments

@viki53
Copy link

viki53 commented Feb 23, 2015

Not really a bug but an enhancement: is there any way to read EXIF data directly form a gm object?

In fact in my script I allow users to upload a photo so I already have the file's data loaded and a gm version of it to get its dimension. I'd like to read the EXIF data if possible without needing another library (and a third heavy variable).

I didn't find anything in the GraphicsMagick doc about reading exif data so I don't know if it's possible at all. Any suggestion?

@ppbntl19
Copy link

ppbntl19 commented Jun 9, 2015

Yes you can use formatting string for reading EXIF data.
http://www.imagemagick.org/script/escape.php

gm(dir + '/image.jpg').identify('%f %m %c %b', function (err, info) {
console.log(info);
})

@lbeschastny
Copy link
Contributor

The right format string for Exif data is %[EXIF:*], so an actual code will look something like

gm(dir + '/image.jpg').identify('%[EXIF:*]', function (err, info) {
  // info is a newline separated string of key=value pairs
  // imagemagick also prefixes each line with "exif:"
  var m, exif = {}, re = /^(?:exif:)?(\w+)=(.+)$/mg;
  while (m = re.exec(info)) {
    exif[m[1]] = m[2];
  }
  console.log(exif);
});

@rishabh6072
Copy link

Is there any way to read Caption[2,120] data directly form a gm object?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants