0

A 'For' loop in my Python 2.7.8 script contains:

ODate = subprocess.check_output(['exiftool', '-datedimeoriginal', image.jpg]) 

Under Windows 7, a Windows console window opens and quickly closes again each time this statement is executed. Not so when running on my Mac (OS X 9).

How can I prevent this?

P.S. ExifTool is a platform-independent Perl library plus a command-line application for reading, writing and editing meta information in a wide variety of files.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Vadersan
  • 9
  • 1
  • possible duplicate of [Running a process in pythonw with Popen without a console](http://stackoverflow.com/questions/1813872/running-a-process-in-pythonw-with-popen-without-a-console) – simonzack Oct 14 '14 at 08:19
  • An alternative to hiding the window is to set the process [creation flags](http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863%28v=vs.85%29.aspx) to `CREATE_NO_WINDOW` or `DETACHED_PROCESS`. See [this answer](http://stackoverflow.com/a/7006424/205580). – Eryk Sun Oct 14 '14 at 08:26
  • It's probably exiftool that is doing this. Far better to avoid calling exiftool. – David Heffernan Oct 14 '14 at 08:27

1 Answers1

0

You don't need to do any of this, launching a separate process for each image to get its EXIF data. Instead, just use Python directly:

from PIL import Image
img = Image.open('image.jpg')
exif_data = img._getexif()
date = exif_data[36867] # DateTimeOriginal

From here: https://stackoverflow.com/a/4765242/4323

Community
  • 1
  • 1
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • Please mark it as a duplicate instead of copying the answer. – simonzack Oct 14 '14 at 08:20
  • 2
    @simonzack: I hardly think this is a duplicate given how different the OP presented the problem. It wasn't a question about EXIF at all really, until I made it one. :) – John Zwinck Oct 14 '14 at 08:21