omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. tomoto-sauce

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Controversial 0
    • Groups 0

    tomoto-sauce

    @tomoto-sauce

    0
    Reputation
    253
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    tomoto-sauce Unfollow Follow

    Latest posts made by tomoto-sauce

    • difference in file-size when using share_image_data(bytesObj) vs. write(bytesObj)

      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!

      posted in Pythonista
      tomoto-sauce
      tomoto-sauce