omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    How to share JPEGs via dialogs.share_image?

    Pythonista
    3
    14
    3361
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • halloleooo
      halloleooo last edited by

      I use dialogs.share_image(img) to share an photo from Pythonista to other apps.

      The photo is given as a PiL image and it seems to be shared as a PNG which is pretty inefficient for photos.

      Any idea how I can share the photo as a JPEG?

      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @halloleooo last edited by

        @halloleooo this shares a jpg

        import console
        console.open_in('a.jpg')
        
        1 Reply Last reply Reply Quote 0
        • halloleooo
          halloleooo last edited by

          Thanks @cvp.

          Does this mean I have save the PIL image first as a JPG to disk and then I can share it?

          cvp 2 Replies Last reply Reply Quote 0
          • ccc
            ccc last edited by

            https://omz-software.com/pythonista/docs/ios/console.html says that console.open_in() takes a file_path.

            1 Reply Last reply Reply Quote 0
            • cvp
              cvp @halloleooo last edited by

              @halloleooo

              import console
              from PIL import Image
              import os
              pil = Image.open('test:Lenna')
              pil.save('test.jpg', quality=95)
              console.open_in('test.jpg')
              os.remove('test.jpg')
              
              1 Reply Last reply Reply Quote 1
              • cvp
                cvp @halloleooo last edited by

                @halloleooo said:

                Does this mean I have save the PIL image first as a JPG to disk and then I can share it

                Yes sir

                cvp 1 Reply Last reply Reply Quote 0
                • halloleooo
                  halloleooo last edited by

                  Thanks for the details. I was hoping to be able to tweak dialogs.share)image to export JPGs, but the detour via a JPG file is ok too.

                  Thanks again!

                  cvp 1 Reply Last reply Reply Quote 0
                  • cvp
                    cvp @halloleooo last edited by

                    @halloleooo said:

                    hoping to be able to tweak dialogs.share)image to export JPGs

                    I don't think it is possible but I can be wrong

                    1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp @cvp last edited by

                      @cvp said:

                      save the PIL image first as a JPG to disk

                      Don't forget that on a iDevice, files are also in RAM 🤔

                      1 Reply Last reply Reply Quote 0
                      • ccc
                        ccc last edited by

                        I woulda said that solid state disk (SDD/flash) != RAM but perhaps someone could correct me.

                        cvp 1 Reply Last reply Reply Quote 0
                        • cvp
                          cvp @ccc last edited by cvp

                          @ccc solid state memory = transistors
                          RAM = read and write memory = transistors too
                          Agree this not the same, specially in access speed, buT not exactly a disk which is in movement...
                          Only different words

                          Anyway, I only wanted to say that they are similar because in solid state material both

                          1 Reply Last reply Reply Quote 0
                          • halloleooo
                            halloleooo last edited by

                            @cvp @ccc Funny, funny., but a good point: These days everything is semiconductors...

                            In regards to the problem at hand: Using the file systems means I have to create a tmpdir first I guess - or where the heck does the stuff get saved when Pythonista executes in a share extension???

                            cvp 1 Reply Last reply Reply Quote 0
                            • cvp
                              cvp @halloleooo last edited by

                              @halloleooo said:

                              where the heck does the stuff get saved when Pythonista executes in a share extension???

                              I guess in the same folder as the script.
                              And no need of temp dir if you remove it just after sharing.

                              1 Reply Last reply Reply Quote 0
                              • ccc
                                ccc last edited by

                                As usual, Python has nice batteries included...
                                https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile

                                1 Reply Last reply Reply Quote 1
                                • First post
                                  Last post
                                Powered by NodeBB Forums | Contributors