Totemi1324
Posts: 5
Joined: Wed Aug 14, 2019 10:20 am

Python library to get EXIF tags from camera?

Fri Jan 03, 2020 2:40 pm

Hello,

I am searching for a way in Python (library etc.) to get the EXIF tags from my RPi Camera v2.1 in the program. Can someone with experience please explain how it works or give a link to an explanation site?

Thanks for the help in advance!

User avatar
thagrol
Posts: 2238
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Python library to get EXIF tags from camera?

Fri Jan 03, 2020 4:05 pm

AIUI, EXIF tags are a property of the image file not of the camera.
  1. What are you actually wanting to get from the camera?
  2. Have you tried RPF/RPT's picamera module? https://picamera.readthedocs.io/en/rele ... index.html
  3. https://www.google.com/search?q=read+ex ... ags+python
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

kaksi
Posts: 107
Joined: Tue Mar 10, 2015 6:19 am

Re: Python library to get EXIF tags from camera?

Fri Jan 03, 2020 10:49 pm

I suppose he means " to get the EXIF tags from pictures from my RPi Camera".

Code: Select all

sudo apt-get install libimage-exiftool-perl
exiftool -s  *.JPG
exiftool -CreateDate -ImageSize -Megapixels *.JPG *.jpg

It is plain Linux, but Python's subprocess.check_output() should do the job.

User avatar
paddyg
Posts: 2464
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Python library to get EXIF tags from camera?

Sat Jan 04, 2020 9:00 am

PIL which is actually Pillow and installed on default raspbian can get most exif data pretty well. Here is a rather complicated demo but the actual exif bit is quite simple.
https://github.com/pi3d/pi3d_demos/blob ... reFrame.py around line 139 and 166. The version of Pillow on buster is quite old and there have been a few fixes on exif reading. I think you can update it using pip3.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

blimpyway
Posts: 211
Joined: Mon Mar 19, 2018 1:18 pm

Re: Python library to get EXIF tags from camera?

Mon Jan 06, 2020 12:04 am

you can execute exif utility and read its output.

Code: Select all

$ sudo apt-get install exif 


$ exif -m file.jpg

Totemi1324
Posts: 5
Joined: Wed Aug 14, 2019 10:20 am

Re: Python library to get EXIF tags from camera?

Tue Jan 07, 2020 8:06 pm

Thanks for the explatations, seems if EXIF tags are rather related to images and not the camera itself. But I am seeking for a way, that while I am running my Python program, I can get info fram my RPi camera such as aperture, exposure time, ISO etc. which the camera sets automatically. I want to especially know the exposure time because from that I can define how light or dark the environment is. This is helpful for determining the daytime of an image.

User avatar
thagrol
Posts: 2238
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Python library to get EXIF tags from camera?

Wed Jan 08, 2020 1:48 am

Totemi1324 wrote:
Tue Jan 07, 2020 8:06 pm
Thanks for the explatations, seems if EXIF tags are rather related to images and not the camera itself. But I am seeking for a way, that while I am running my Python program, I can get info fram my RPi camera such as aperture, exposure time, ISO etc. which the camera sets automatically. I want to especially know the exposure time because from that I can define how light or dark the environment is. This is helpful for determining the daytime of an image.
The information you want is mostly available via the picamera class: https://picamera.readthedocs.io/en/rele ... e-picamera

However, exposure time alone isn't enough to tell how dark or light the environment is. Exposure time will be affected by ISO and othe gain settings. Change one you change the other. See here for an explanation but ignore aperture changes as it's fixed on the camera modules: https://photographylife.com/what-is-exposure-triangle
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

Return to “Python”