Skip to content

Commit 6f964d7

Browse files
committed
fix: [exifs module] Mp4 UnidentifiedImageError
1 parent f4584f7 commit 6f964d7

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

bin/modules/Exif.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import os
1313
import sys
1414

15-
from PIL import Image, ExifTags
15+
from PIL import Image, ExifTags, UnidentifiedImageError
1616

1717
sys.path.append(os.environ['AIL_BIN'])
1818
##################################
@@ -38,22 +38,25 @@ def __init__(self):
3838
def compute(self, message):
3939
image = self.get_obj()
4040
print(image)
41-
img = Image.open(image.get_filepath())
42-
img_exif = img.getexif()
43-
print(img_exif)
44-
if img_exif:
45-
self.logger.critical(f'Exif: {self.get_obj().id}')
46-
gps = img_exif.get(34853)
47-
print(gps)
48-
self.logger.critical(f'gps: {gps}')
49-
for key, val in img_exif.items():
50-
if key in ExifTags.TAGS:
51-
print(f'{ExifTags.TAGS[key]}:{val}')
52-
self.logger.critical(f'{ExifTags.TAGS[key]}:{val}')
53-
else:
54-
print(f'{key}:{val}')
55-
self.logger.critical(f'{key}:{val}')
56-
sys.exit(0)
41+
try:
42+
img = Image.open(image.get_filepath())
43+
img_exif = img.getexif()
44+
print(img_exif)
45+
if img_exif:
46+
self.logger.critical(f'Exif: {self.get_obj().id}')
47+
gps = img_exif.get(34853)
48+
print(gps)
49+
self.logger.critical(f'gps: {gps}')
50+
for key, val in img_exif.items():
51+
if key in ExifTags.TAGS:
52+
print(f'{ExifTags.TAGS[key]}:{val}')
53+
self.logger.critical(f'{ExifTags.TAGS[key]}:{val}')
54+
else:
55+
print(f'{key}:{val}')
56+
self.logger.critical(f'{key}:{val}')
57+
sys.exit(0)
58+
except UnidentifiedImageError:
59+
self.logger.info(f'Invalid image: {image.get_filepath()}')
5760

5861
# tag = 'infoleak:automatic-detection="cve"'
5962
# Send to Tags Queue

0 commit comments

Comments
 (0)