MacsandaPi
Posts: 103
Joined: Tue Dec 30, 2014 7:44 pm

How to read EXIF data?

Sat Nov 12, 2016 2:08 am

The blog announcing Pixel (https://www.raspberrypi.org/blog/introducing-pixel/) mentions that the EXIF data of the new wallpaper photos would tell where the photos were taken. So, how does one read the EXIF data?

Google led me to try "imagemagick," but sudo apt-get install puts two copies of the app in the Graphics menu on my RPi B+, but neither one will launch.

Is this the recommended app for reading EXIF data on the Pi? Help would be appreciated. Thanks.

User avatar
scruss
Posts: 3212
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: How to read EXIF data?

Sat Nov 12, 2016 4:13 am

try either jhead or exiftool
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
DougieLawson
Posts: 39120
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: How to read EXIF data?

Sat Nov 12, 2016 10:14 am

Code: Select all

from PIL import Image
from PIL.ExifTags import TAGS
img = Image.open('cam.jpg')
exif_data = img._getexif()
for tag, value in exif_data.items():
  print TAGS.get(tag, tag), value
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
scruss
Posts: 3212
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: How to read EXIF data?

Sat Nov 12, 2016 6:13 pm

I did this with exiftool: Greg Annandale's photo locations for Raspberry Pi Foundation's PIXEL wallpaper. The images are a bit hard to identify from it, but they are there.

If you're a Google Earth user (I don't think there's a version for Raspberry Pi) you can use this KML: Greg Annandale's photo locations for Raspberry Pi Foundation's PIXEL wallpaper KML.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

MacsandaPi
Posts: 103
Joined: Tue Dec 30, 2014 7:44 pm

Re: How to read EXIF data?

Sun Nov 13, 2016 2:51 am

DougieLawson wrote:

Code: Select all

from PIL import Image
from PIL.ExifTags import TAGS
img = Image.open('cam.jpg')
exif_data = img._getexif()
for tag, value in exif_data.items():
  print TAGS.get(tag, tag), value
Thanks for your reply, Dougie. I need to work with the code some more; I get a syntax error at "print TAGS."

MacsandaPi
Posts: 103
Joined: Tue Dec 30, 2014 7:44 pm

Re: How to read EXIF data?

Sun Nov 13, 2016 2:58 am

[quote="scruss"]I did this with exiftool: Greg Annandale's photo locations for Raspberry Pi Foundation's PIXEL wallpaper. The images are a bit hard to identify from it, but they are there.

Thanks for this; you've done the work for me! I installed exiftool and found it worked well. Before looking at the EXIF data, I just assumed that the locations would be identified in text and not by coordinates. Always learning new stuff with the RPi. Thanks again.

User avatar
DougieLawson
Posts: 39120
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: How to read EXIF data?

Sun Nov 13, 2016 8:37 am

MacsandaPi wrote: Thanks for your reply, Dougie. I need to work with the code some more; I get a syntax error at "print TAGS."
It's python2 not python3.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
rpdom
Posts: 17172
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: How to read EXIF data?

Sun Nov 13, 2016 8:44 am

DougieLawson wrote:
MacsandaPi wrote: Thanks for your reply, Dougie. I need to work with the code some more; I get a syntax error at "print TAGS."
It's python2 not python3.
Why are you still using Python 2? Pretty much everything Pi related is Python 3 now.

User avatar
DougieLawson
Posts: 39120
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: How to read EXIF data?

Sun Nov 13, 2016 8:56 am

rpdom wrote:
DougieLawson wrote:
MacsandaPi wrote: Thanks for your reply, Dougie. I need to work with the code some more; I get a syntax error at "print TAGS."
It's python2 not python3.
Why are you still using Python 2? Pretty much everything Pi related is Python 3 now.
Because I couldn't be ***sed to fix that small simple sample.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
scruss
Posts: 3212
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: How to read EXIF data?

Sun Nov 13, 2016 4:00 pm

MacsandaPi wrote: I just assumed that the locations would be identified in text and not by coordinates
For that you need a reverse geocoder, such as OpenStreetMap's Nominatim. That might be a more fun programming project, as you have to decide what to do if you get zero results back, or which to choose if you get many results back. It's also quite a small server, so you have to be careful with hitting it with too many requests.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Return to “Beginners”