@@ -133,7 +133,7 @@ def decode_base64_to_image(encoding):
133
133
user_input_data = {}
134
134
135
135
136
- def set_img_exif_dict ():
136
+ def set_img_exif_dict (image_id = "img_id_1" ):
137
137
print (f"log@{ datetime .datetime .now ().strftime (f'%Y%m%d%H%M%S' )} ***&&& set_img_exif_dict Writing exif" )
138
138
title = "AIRI"
139
139
date_taken = "2001:01:01 01:01:01"
@@ -146,10 +146,12 @@ def set_img_exif_dict():
146
146
user_id = "AIRI tester"
147
147
if "user_id" in user_input_data :
148
148
user_id = user_input_data ['user_id' ]
149
- keywords = "Generated in AIRI platform. https://airilab.com"
150
- description = "An image processed by the AIRI platform."
149
+ generation_id = "gen_id_1"
150
+ if "generation_id" in user_input_data :
151
+ generation_id = user_input_data ['generation_id' ]
152
+ keywords = "Generated in AIRI platform. https://airilab.com . Generation ID: {generation_id}, Image ID: {image_id}"
153
+ description = f"An image processed by the AIRI platform. Generation ID: { generation_id } , Image ID: { image_id } "
151
154
software = "AIRI Platform v1.0"
152
- # imageid = "imageid?"
153
155
# imagenum = "imagenum?"
154
156
# seed = "seed?"
155
157
exif_dict = {
@@ -231,12 +233,12 @@ def encode_pil_to_base64(image):
231
233
# })
232
234
233
235
# Convert dict to bytes
234
- exif_bytes = piexif .dump (set_img_exif_dict ())
236
+ exif_bytes = piexif .dump (set_img_exif_dict ()) # Doesn't work here even though the exif is confirmed to have been added here
235
237
236
238
if opts .samples_format .lower () in ("jpg" , "jpeg" ):
237
239
image .save (output_bytes , format = "JPEG" , exif = exif_bytes , quality = opts .jpeg_quality )
238
- print (f"log@{ datetime .datetime .now ().strftime (f'%Y%m%d%H%M%S' )} ***&&& encode_pil_to_base64" )
239
- print (Image .open (output_bytes ).getexif ()) # Print the EXIF data
240
+ # print(f"log@{datetime.datetime.now().strftime(f'%Y%m%d%H%M%S')} ***&&& encode_pil_to_base64")
241
+ # print(Image.open(output_bytes).getexif()) # Print the EXIF data
240
242
else :
241
243
image .save (output_bytes , format = "WEBP" , exif = exif_bytes , quality = opts .jpeg_quality )
242
244
@@ -948,30 +950,24 @@ def post_invocations(self, b64images, quality):
948
950
key = key [ : - 1 ]
949
951
images = []
950
952
for b64image in b64images :
953
+ image_id = datetime .datetime .now ().strftime (f"%Y%m%d%H%M%S-{ uuid .uuid4 ()} " )
954
+ suffix = opts .samples_format .lower ()
951
955
img = decode_to_image (b64image )
952
- if opts .samples_format .lower () in ("jpg" , "jpeg" , "webp" ):
953
- print (f"log@{ datetime .datetime .now ().strftime (f'%Y%m%d%H%M%S' )} ***&&& post_invocations_before" )
954
- # Create a file-like object from the image object
955
- # image_file = BytesIO(img.tobytes())
956
- # image = Image.open(image_file)
957
- # print(image.getexif()) # Print the EXIF data
958
- print (img .getexif ()) # Print the EXIF data
956
+ if opts .samples_format .lower () in ("jpg" , "jpeg" ):
957
+ # print(f"log@{datetime.datetime.now().strftime(f'%Y%m%d%H%M%S')} ***&&& post_invocations_before")
958
+ # print(img.getexif()) # Print the EXIF data
959
959
960
960
# Save the image with the EXIF data
961
- exif_bytes = piexif .dump (set_img_exif_dict ())
962
- # image.save(img, format="JPEG", exif=exif_bytes, quality=opts.jpeg_quality)
961
+ exif_bytes = piexif .dump (set_img_exif_dict (image_id = image_id ))
963
962
with io .BytesIO () as output_bytes :
964
963
img .save (output_bytes , format = "JPEG" , exif = exif_bytes , quality = opts .jpeg_quality )
965
964
output_bytes .seek (0 ) # Go back to the start of the BytesIO object
966
- img_after = Image .open (output_bytes )
967
- print (f"log@{ datetime .datetime .now ().strftime (f'%Y%m%d%H%M%S' )} ***&&& post_invocations_after" )
968
- print (img_after .getexif ()) # Print the EXIF data
965
+ # img_after = Image.open(output_bytes)
966
+ # print(f"log@{datetime.datetime.now().strftime(f'%Y%m%d%H%M%S')} ***&&& post_invocations_after")
967
+ # print(img_after.getexif()) # Print the EXIF data
969
968
970
969
bytes_data = export_pil_to_bytes (img , quality )
971
970
# bytes_data = export_pil_to_bytes(decode_to_image(b64image), quality)
972
-
973
- image_id = datetime .datetime .now ().strftime (f"%Y%m%d%H%M%S-{ uuid .uuid4 ()} " )
974
- suffix = opts .samples_format .lower ()
975
971
shared .s3_client .put_object (
976
972
Body = bytes_data ,
977
973
Bucket = bucket ,
0 commit comments