Here's how to do it with RMagick:
image = Magick::Image.read('/users/jimjames99/desktop/cat.jpg').first
=> /users/jimjames99/desktop/cat.jpg JPEG 500x295 500x295+0+0 DirectClass 8-bit 132kb
>> image.get_exif_by_entry('DateTime')
=> [["DateTime", "2007:07:31 14:18:15"]]
If there is no date/time encoded into the picture you get this result:
=> [["DateTime", ""]]
There are lots of other EXIF entries that you can query, including make and model of the camera, picture settings, and so on. The specification is here (pdf).
A couple of factors conspire to frustrate this user helper. iPhoto and other picture gallery programs tend to either wipe the EXIF data from pictures or removes it when you export the pictures to upload to another system (like the travel portal). And of course just because the traveler took the picture in Rome doesn't mean that they want to show it on the Rome page. So we have to provide a robust picture assignment functionality. More on that another time.
0 comments:
Post a Comment