I'm having a weird issue when trying to save a PIL image to disk.
Using the same input data with 2 different save methods, I'm getting significantly different file sizes for the resulting file-on-disk. In the case of very large images (4000px wide), the difference can be as much as 4 MB!
The process I'm using is exactly the same as the one used in dialogs.share_image_data():
fileRepr_temp = io.BytesIO() # create stream to in-memory resource
pilImg.save(fileRepr_temp, 'PNG' )
img_data = fileRepr_temp.getvalue() # get a bytes obj
then afterwards:
# save to disk using iOS
(rstr, rlist) = dialogs.share_image_data(img_data)
# save to disk by writing bytes obj to file
fileRepr = open(pathStr, mode='wb')
fileRepr.seek(0)
fileRepr.write(img_data)
fileRepr.close()
For some reason, the file saved through iOS is significantly smaller than the one created using write(). I'd like to be able to write this same smaller file-size without having to call the iOS dialogue (this is part of a batch-processing script).
Unfortunately I don't know enough about file IO to understand what's going on here. :(
Any help would be appreciated!