Closed AntoineVe closed 8 years ago
I'm not familiar with exif.txt
. What is its purpose? How would it be used?
@justinmayer The Photos plugin uses two text files "exif.txt" and "captions.txt" to hold one-line comments for each photo. Generating those files was left as an exercise for the reader, since I do it in separate pass.
The major issue is that exiftool is written in Perl, and accessing it from Python seems like a hack. However, I could not force myself to write a complete Perl solution :-)
@AntoineVe Here is the Python script that I am using:
#!/usr/bin/python
import sys
import subprocess
import os
from PIL import Image, ExifTags
import exiftool
proc= exiftool.ExifTool("/Users/px/Programming/exiftool")
proc.start()
for path in sys.argv[1:]:
r= proc.execute_json(
"-EXIF:Make", "-EXIF:Model", "-EXIF:FocalLength", "-EXIF:FNumber",
"-EXIF:ExposureTime", "-EXIF:ISO", "-EXIF:Flash", "-EXIF:ExposureCompensation",
path)[0]
make = r.get("EXIF:Make", "")
model= r.get("EXIF:Model", "")
lens = r.get("EXIF:FocalLength", 0)
f = r.get("EXIF:FNumber", 0)
time = r.get("EXIF:ExposureTime", 1)
iso = r.get("EXIF:ISO", None)
flash= r.get("EXIF:Flash", 0)
expo = r.get("EXIF:ExposureCompensation", 0)
if not model:
continue
mm= ""
if lens:
mm=(' %dmm' % (lens,))
if model=="Canon EOS 350D DIGITAL":
model= 'Canon EOS 350D';
mm=('%s (%d eq)' % (mm, float(lens)*1.6))
exif= ( (model if model.startswith(make) else make + ' ' + model) +
' -' + mm +
(' f/%.1f' % (f,)).replace('.0', '') +
((' 1/%ds' % (1/time+0.5,)) if time < 1 else ' %ds' % (time,)) +
(' %1.1fEV' % (expo,) if expo else '') +
(' ISO %d' % (iso,)) if iso else '' +
' Flash' if (flash & 1) else '')
try:
print path + ": " + exif
except:
print path
print exif
raise
proc.terminate()
@justinmayer sorry, I haven't said this issue is for the photo plugin.
@pxquim using exiftool module and PIL is an interessing solution, I will do some comparison because the bash script is a little bit slow.
@AntoineVe Actually the PIL import is a leftover from a previous version of the script when I actually tried to use PIL. My conclusion at the time is that the Perl exiftool is more mature and overall easier to use.
Rewriting everything is Perl is on my TODO list, but this script is good enough for my needs at this point, even if it is a gross hack.
Maybe add in the Readme how to quickly create exif.txt : e.g. :
Then someting like
touch exif.txt && find ./ -type f -name '*.jpg' -exec ~/exif_extract.sh {} \; >> exif.txt
If you ask me, I'll write a more complete python script to generate the
exif.txt
.