1212import os
1313import sys
1414
15- from PIL import Image , ExifTags
15+ from PIL import Image , ExifTags , UnidentifiedImageError
1616
1717sys .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