@jm2466 this
# 1) convert PIL Image to ui.Image console.hud_alert('convert PIL Image into ui.Image') with io.BytesIO() as bIO: new_im.save(bIO, 'PNG') ui_image = ui.Image.from_data(bIO.getvalue()) del bIO # 2) Create a PHAsset from an ui.Image (not from a PIL Image) console.hud_alert('Create a PHAsset from an ui.Image') lib = PHPhotoLibrary.sharedPhotoLibrary() def change_block(): req = PHAssetChangeRequest.creationRequestForAssetFromImage_(ui_image) def perform_changes(): lib.performChangesAndWait_error_(change_block, None) t = threading.Thread(target=perform_changes) t.start() t.join()is about (π) 1000 x slower than
path = 'temp.jpg' new_im.save(path , quality=95) photos.create_image_asset(path) os.remove(path)