5

Is there any way to read jpg metadata with javascript? My main interest is the xmp rating value (rating of 5 stars showing in Windows Explorer). Also the time when the picture was taken is of interest.

I know I can get this data using server side code, but I'd like to avoid the extra roundtrip to get this info.

My use case is a simple gallery website, where I'd like to show the rating given in Windows Explorer, and possibly things like when the picture was taken etc.

hazard
  • 418
  • 5
  • 10
  • you should really make that info available at the time you publish the page. while you can obtain the info from binary files, it's relatively expensive, fragile, and slow to do so, not something that every visitor should be forced to do each visit. – dandavis Jul 16 '13 at 19:12
  • The content is dynamic (I want new photos to be added automatically), so making this info available before a "publish", is not an option for me. I was hoping the metadata was already sent to the client (thinking that the whole image file is sent over the wire), but looking into it I'm starting to think this is not the case. – hazard Jul 17 '13 at 19:42
  • well, you *can* incorporate a meta updater in whatever makes the images "added automatically", since that surely is a server-side process of some sort... – dandavis Jul 17 '13 at 20:08
  • Ok, I've settled with what I was hoping was possible is not very easy to do, so I'll do the job on the server side. Thanks for your comments. – hazard Jul 19 '13 at 09:13
  • I'm trying to find the same information. flickr wrote a blog post covering how they do it. http://code.flickr.net/2012/06/01/parsing-exif-client-side-using-javascript-2/ However, this seems to be mostly for camera specific stuff, not user descriptive stuff like ratings, and tags, etc. – bodine Oct 15 '14 at 20:28

1 Answers1

2

XMP Metadata in a JPEG is actually just plain text embedded into the JPEG.

If you open a JPEG as a text file and ctr-f "xmp" you will be brought to the XMP metadata. It will be in xml format.

In javascript, you can just use the file reader api to read the text and then parse the xmp string to retrieve the info you are looking for.

Sam K
  • 319
  • 1
  • 6
  • 13