lawoo.blogg.se

Exiftool
Exiftool







exiftool

Windoze may have a problem with long lists of files, so you my need to do it using an argfile. 'STDOUT:' + () if isinstance(res.stdout, bytes) else res.stdout) Res = n(batchup, capture_output=True)Įrrdata=('STDERR:\n' + () if isinstance(res.stderr, bytes) else res.stderr + exiftool will handle any number of files at a time, so to process a bunch of files, and extract specific metadata fields, this goes about 8 times faster on my laptop: def meta_for_batch(fieldlist, filelist):īatchup = + fieldlist + filelist 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 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"):

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. To avoid launching a new process for each image, you should start exiftool using the -stay_open flag.









Exiftool