Optimisation lors du traitement des tags : gain x10 en temps d'exécution
This commit is contained in:
parent
2dce5901e3
commit
0a4a75647a
24
exv.py
24
exv.py
@ -78,15 +78,21 @@ def extractor(input_files, start, end, recursive, extensions):
|
||||
if not isfile(input_file):
|
||||
raise ValueError("{} doesn't exist here.".format(input_file))
|
||||
exif_dict.update({'file': input_file})
|
||||
for extracted in usefull_exif:
|
||||
cmd = ["exiv2", "-g", extracted, "-Pt", input_file]
|
||||
with Popen(cmd, stdout=PIPE) as extracted_data:
|
||||
extracted_data = extracted_data.stdout.read().decode()
|
||||
if extracted_data:
|
||||
extracted_data = extracted_data.splitlines()[0]
|
||||
exif_dict.update({extracted.split(".")[-1]: extracted_data})
|
||||
else:
|
||||
exif_dict.update({extracted.split(".")[-1]: None})
|
||||
cmd = ["exiv2", "-Ptk", input_file]
|
||||
with Popen(cmd, stdout=PIPE) as extracted_data:
|
||||
extracted_data = extracted_data.stdout.read().decode()
|
||||
for line in extracted_data.splitlines():
|
||||
for exif in usefull_exif:
|
||||
if exif in line.split()[0]:
|
||||
exif_dict.update(
|
||||
{
|
||||
line.split()[0].split(".")[-1]:
|
||||
" ".join(line.split()[1:])
|
||||
}
|
||||
)
|
||||
for exif in usefull_exif:
|
||||
if exif.split(".")[-1] not in exif_dict:
|
||||
exif_dict.update({exif.split(".")[-1]: None})
|
||||
if exif_dict['FocalLength']:
|
||||
exif_dict['FocalLength'] = float(
|
||||
exif_dict['FocalLength'].replace(" mm", ""))
|
||||
|
Loading…
Reference in New Issue
Block a user