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.


    Containers for photos, with scroll, drag&drop between them

    Pythonista
    2
    47
    16766
    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.
    • cvp
      cvp @jmv38 last edited by

      @jmv38 said:

      but it still doesnt work: now the button shows in gray, not white, and is not visible on my gray background.
      I wonder how to get it simply as it shows in the editor?

      You asked gray and I didn't know you had a gray background

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

        @cvp i have finished my first version of the program
        here https://gist.github.com/1b67ba85ca7bd7b23c7058216895372c
        this will:

        • let you choose an album xxxx
        • load the 200 first pictures
        • present them in a photopicker
        • from which you can build photo album pages (collage)
        • it creates 2 new albums:
        • xxxx_pages : the album pages
        • xxxx_pages_and_photos: as it says. useful to upload the album in photoweb printing service for instance
        • your own photos and albums are not modified

        to see how to use it tap ‘?’ button: it opens a youtube video that shows it in action.

        It is designed to work in lanscape mode
        let me know how it works for you.

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

          @cvp hello again!

          I am trying to make a high definition image with draw_snapshot()
          I works fine until the context width is 4000, but i get a black image when the context width is 5000 or more. I need 9000....
          Any suggestion?
          Thanks.

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

            @jmv38 Sorry, I forgot to tell you, 20 days ago, I had tried your Appli.py it I don't have any album in my photos, thus I tap the X in the first screen, and your program crashes in line
            inputAlbum = allAlbums[inputTitle] 😢

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

              @jmv38 this works for me

              import ui
              iv = ui.ImageView()
              iv.image = ui.Image.named('P1020096.JPG') # 3888 x 2592 pixels
              wi,hi = iv.image.size
              iv.frame = (0,0,wi,hi)
              print(wi,hi)															# 3888 2592
              w = 2*wi
              h = 2*hi
              print(w,h)																# 7776 5184
              with ui.ImageContext(w,h) as ctx:
              	iv.draw_snapshot()
              	ui_image = ctx.get_image()
              	with open('t1.jpg', 'wb') as f:
              		f.write(ui_image.to_jpeg(0.9))			# 15552 x 10368 
              
              1 Reply Last reply Reply Quote 0
              • cvp
                cvp last edited by

                But 9000 x 6000 crashes..

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

                  @cvp thank for the info
                  i check again

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

                    @cvp i had forgotten that 4000 is really 8000 because x2
                    i think 8000 should be enough for prints 60 cm wide => thanks. you saved my last week of coding!

                    However it is strange that 15000 is ok bu not 9000...?

                    Concerning the use of the project without any album, i could modify this for you if you are really interested in using this code. Are you?

                    thanks.

                    cvp 3 Replies Last reply Reply Quote 0
                    • cvp
                      cvp @jmv38 last edited by

                      @jmv38 Not interested actually, thanks. If needed, I'll create an album.

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

                        @jmv38 During my tests and my multiple crashes, I'm pretty sure I have seen a red message during one microsecond, containing the words Decompression Bombs

                        This is a [PIL message](Decompression Bombs) .
                        I didn't use PIL. Perhaps the ui.Image.save uses it...

                        Something like, it not sure, message disappeared immediately
                        /usr/lib64/python2.6/site-packages/PIL/Image.py:2261: DecompressionBombWarning: Image size (166109750 pixels) exceeds limit of 89478485 pixels, could be decompression bomb DOS attack. DecompressionBombWarning)

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

                          @jmv38 said:

                          However it is strange that 15000 is ok bu not 9000...?

                          15000 is in pixel, already multiplied by 2. The width was 7776, just < 9000

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

                            Same crash with

                            Image.warnings.simplefilter('error', Image.DecompressionBombWarning)
                            Image.MAX_IMAGE_PIXELS = 100000000000
                            
                            1 Reply Last reply Reply Quote 0
                            • jmv38
                              jmv38 @cvp last edited by

                              @cvp 5000 doesnt work for me and 5000<7000

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

                                @jmv38 and Sure that you don't have two pixels py point?
                                What is your device?

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

                                  @cvp i do have 2 pixels per point (ipad air)
                                  i dont crash, it is just that the image saved is black
                                  i checked that 4x1024 is ok and 4x1025 fails
                                  i remember this ios limit 4096 from somwhere.

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

                                    @jmv38 could you post your code, only this part, and the image you use?

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

                                      @cvp just to let you know here is my code.
                                      It wont run because the rest of the code is missing, but it gives you the idea

                                      def save(self):
                                          # make a hi resolution copy of back & images, then save it in camera roll
                                          xo, yo, w, h = self.page.back.frame
                                          c = self.page.back.background_color
                                          targetWidth = 4*1024
                                          s = targetWidth / w
                                          w, h = w*s, h*s
                                          page = ui.View( frame=(0,0,w,h), background_color=c)
                                          views = []
                                          for thumb in self.thumbs:
                                            x,y,w,h = thumb.frame
                                            x,y,w,h = (x-xo)*s, (y-yo)*s, w*s, h*s
                                            v = ui.View( frame=(x,y,w,h) )
                                            x,y,w,h = thumb.iv.frame
                                            x,y,w,h = x*s, y*s, w*s, h*s
                                            img = thumb.getImage(thumb.asset)
                                            iv = ui.ImageView(frame=(x,y,w,h), image=img)
                                            v.add_subview(iv)
                                            page.add_subview(v)
                                            views.append(v)
                                          # save page image in pythonista
                                          getTopView().add_subview(page)
                                          #page.bring_to_front()
                                          #if True: return
                                          path = 'temp.jpg'
                                          with ui.ImageContext(page.width, page.height) as ctx:
                                            page.draw_snapshot()                            
                                            ui_image = ctx.get_image()
                                          pil = Image.open(io.BytesIO(ui_image.to_png()))
                                          pil.save(path , quality=99)
                                          # save page image in albums
                                          asset = photos.create_image_asset(path)
                                          os.remove(path)
                                          getTopView().remove_subview(page)
                                          views = False
                                          console.hud_alert('saved')
                                      

                                      looks like i must add the view to the screen to get the draw snapshot to work.

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

                                        @jmv38 said:

                                        looks like i must add the view to the screen to get the draw snapshot to work.

                                        Not at all, I think. You've seen my little code, nothing goes to the screen

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

                                          @cvp you are correct. My pb was pbly sthg else.

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

                                            @jmv38 The only 4096 limit I find for iPad Air is Max OpenGL Texture Sizes

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