tnc-ca-geo / animl-email-relay

Lambda service for extracting camera trap images from email attachments
Other
0 stars 0 forks source link

Fix `format_and_merge_exif_data()` method for Cuddelinks #17

Open nathanielrindlaub opened 1 year ago

nathanielrindlaub commented 1 year ago

@postfalk - when I do pass in a Cuddelink email with attached images, the self.get_extra_exif() method correctly extracts the EXIF from the image, but the self.format_and_merge_exif_data() then returns an empty dict. I'm sure this is something minor & I can look into it an fix it, but I'm concerned why the cameras test wouldn't have caught this.

Also - mind if I rename the get_extra_exif method? I consider EXIF data the metadata that we extract directly from the image file using Exiftool; the "extra" stuff is more what we extract from other parts of the email (body, subject line, etc) and then write to the images' EXIF data.

Here's an example of the extra_exif returned by an image:

[{'SourceFile': '/tmp/tmpxnldqdvw/T_00001.JPG', 'ExifTool:ExifToolVersion': 12.61, 'ExifTool:Warning': 'Invalid EXIF text encoding for UserComment', 'File:FileName': 'T_00001.JPG', 'File:Directory': '/tmp/tmpxnldqdvw', 'File:FileSize': 54692, 'File:FileModifyDate': '2023:06:16 11:10:04+00:00', 'File:FileAccessDate': '2023:06:16 11:10:04+00:00', 'File:FileInodeChangeDate': '2023:06:16 11:10:04+00:00', 'File:FilePermissions': 100664, 'File:FileType': 'JPEG', 'File:FileTypeExtension': 'JPG', 'File:MIMEType': 'image/jpeg', 'File:ExifByteOrder': 'II', 'File:ImageWidth': 960, 'File:ImageHeight': 558, 'File:EncodingProcess': 0, 'File:BitsPerSample': 8, 'File:ColorComponents': 3, 'File:YCbCrSubSampling': '2 1', 'EXIF:Make': 'CUDDEBACK', 'EXIF:Model': 'LL2A', 'EXIF:Software': 'LL2A FW 1.2.0', 'EXIF:ModifyDate': '2023:05:28 09:21:24', 'EXIF:Copyright': 'Copyright Cuddeback, 2023', 'EXIF:Orientation': 1, 'EXIF:XResolution': 72, 'EXIF:YResolution': 72, 'EXIF:ResolutionUnit': 2, 'EXIF:YCbCrPositioning': 2, 'EXIF:ExifVersion': '0221', 'EXIF:DateTimeOriginal': '2023:05:28 09:21:24', 'EXIF:CreateDate': '2023:05:28 09:21:24', 'EXIF:ExposureTime': 0.004, 'EXIF:FNumber': 2.7, 'EXIF:MeteringMode': 5, 'EXIF:WhiteBalance': 0, 'EXIF:ColorSpace': 1, 'EXIF:Flash': 0, 'EXIF:ExposureProgram': 2, 'EXIF:ISO': 160, 'EXIF:ExifImageWidth': 960, 'EXIF:ExifImageHeight': 558, 'EXIF:UserComment': 'MR=C.1,AD=4/12/2023,LD=47,BT=13,RD=46,LH=0,LI=201,BL=8158,BP=75%,BS=EXT,BD=47,BI=281,CF=Enabled,EX=WIDE,LO=006,MA=27206D338046,SM=EZ,DD=AUTO,DI=1,DL=OFF,ND=AUTO,NI=1,NL=OFF,CD=5SEC,FP=/DCIM/100CUDDY/I__00111.JPG,FC=D75C78B2', 'Composite:Aperture': 2.7, 'Composite:ImageSize': '960 558', 'Composite:Megapixels': 0.53568, 'Composite:ShutterSpeed': 0.004, 'Composite:LightValue': 10.1536311941017}]

and self.format_and_merge_exif_data(extra_data=extra_exif) for that same image returns an empty dict {}.

postfalk commented 1 year ago

Feel free to update as you like. But before committing please update tests. I will not be able to look at this before Monday.

nathanielrindlaub commented 1 year ago

Oh, I'm now seeing that there aren't any tests other than test_evaluate_make() for Cuddelinks. I'll look into it and try to add some.