

This still turns up in searches, but using stay open etc, is barely faster than just running up subprocess individually for each file. directory find and execute on every document found. Print(json.dumps(tadata_lookup, indent=3)) tadata_lookup = self.get_metadata(FileLoc) Return json.loads(self.execute("-G", "-j", "-n", *FileLoc))įor dirname, dirnames, filenames in os.walk(locDir):

> 30 (str.join("\n", args))ĪttributeError: 'ExifTool' object has no attribute 'process' return follow ERROR using Python 3.8.10 and IPYTHON Otherwise the program will hang because the while loop inside execute() won't stop
#Exiftool windows series
The second is that you have to decode the byte series returned by os.read(): output += os.read(fd, 4096).decode('utf-8')ĮDIT for Windows: To get this working on Windows, the sentinel need to be changed into "\r\n" The first is an additional argument to subprocess.Popen: self.process = subprocess.Popen( To get this to work in python 3 two small changes are needed. This class is written as a context manager to ensure the process is exited if you are done. Return json.loads(self.execute("-G", "-j", "-n", *filenames)) Stdin=subprocess.PIPE, stdout=subprocess.PIPE)ĭef _exit_(self, exc_type, exc_value, traceback): I also included get_metadata() to read the metadata in JSON format: import subprocessĭef _init_(self, executable="/usr/bin/exiftool"): Here's a simple class that launches an exiftool process and features an execute() method to send commands to that process. ExifTool supports JSON output, which is probably the best option for reading the metadata.

You can then send commands to the process via stdin, and read the output on stdout. It can additionally rename files, organize them in directories (by date or any other meta-information), copy/delete meta information between files (even different-format files), and read/write structured XMP information.To avoid launching a new process for each image, you should start exiftool using the -stay_open flag. It will allow for numerous output formatting options (including tab-delimited, HTML, XML, and JSON), multilingual output, and the ability to quickly extract thumbnail images, preview images, and large JPEG images directly from RAW files.ĮxifTool also can geotag images from GPS track log files (with time drift correction), generate track logs from geotagged images, and fix image timestamps. ExifTool will read and write maker-notes of most of the popular digital cameras. This highly customizable tool allows a great deal of personalization and offers fast and flexible features that will make it usable in almost any situation. It supports many different metadata formats, including EXIF, GPS, IPTC, XMP, JFIF, GeoTIFF, ICC Profile, Photoshop IRB, FlashPix, AFCP, and ID3, as well as the maker notes of many digital cameras by Canon, Casio, FLIR, FujiFilm, GE, HP, JVC/Victor, Kodak, Leaf, Nikon, Nintendo, Minolta/Konica-Minolta, Olympus/Epson, Panasonic/Leica, Pentax/Asahi, Phase One, Reconyx, Ricoh, Samsung, Sanyo, Sigma/Foveon, and Sony.
#Exiftool windows free
ExifTool is a free command-line application for reading, writing, and editing meta information in various files.
