Page 1 of 1

Python library to get EXIF tags from camera?

Posted: Fri Jan 03, 2020 2:40 pm
by Totemi1324
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!

Re: Python library to get EXIF tags from camera?

Posted: Fri Jan 03, 2020 4:05 pm
by thagrol
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

Re: Python library to get EXIF tags from camera?

Posted: Fri Jan 03, 2020 10:49 pm
by kaksi
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.

Re: Python library to get EXIF tags from camera?

Posted: Sat Jan 04, 2020 9:00 am
by paddyg
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.

Re: Python library to get EXIF tags from camera?

Posted: Mon Jan 06, 2020 12:04 am
by blimpyway
you can execute exif utility and read its output.

Code: Select all

$ sudo apt-get install exif 


$ exif -m file.jpg

Re: Python library to get EXIF tags from camera?

Posted: Tue Jan 07, 2020 8:06 pm
by Totemi1324
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.

Re: Python library to get EXIF tags from camera?

Posted: Wed Jan 08, 2020 1:48 am
by thagrol
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