@tomoto-sauce, I simulated what share_image_data might be doing and converted the PIL to an ui.Image (UIImage) before saving (#3, below).

The results... The file sizes of #1 and #3 are the same, and all are PNGs, but in the case of my image, their size was almost 16 MB while the plain byte dump in #2 was about 11 MB. This sounds like the reverse of what you found.

import io import dialogs import photos import ui pil = photos.get_assets()[-1].get_image() with io.BytesIO() as tmp: pil.save(tmp, 'PNG') img_data = tmp.getvalue() # 1 dialogs.share_image_data(img_data) # 2 with open('experiment2.png', mode='wb') as fp: fp.write(img_data) # 3 img = ui.Image.from_data(img_data) with open('experiment3.png', mode='wb') as fp: fp.write(img.to_png())