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.


    Export Canvas button?

    Pythonista
    canvas update export
    4
    11
    8373
    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.
    • brumm
      brumm last edited by

      canvas.draw_clipboard(x,y,width,height)
      photos.save_image(clipboard.get_image())
      
      ExParrot 1 Reply Last reply Reply Quote 0
      • ExParrot
        ExParrot @brumm last edited by

        @brumm :
        Thanks! Now I have a good use for the new auto load feature. I'll make that a script called ExPortit(). 🤓

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

          That snippet assumes the desired image is on (part of) the clipboard. I'll have to tweak it to use the whole canvas...

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

            clipboard.get_image() doesn't return a PIL Image, it's returning None 🙁. So the Pythonista 1.5 way doesn't work.

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

              Are you sure you had an image on the clipboard when you called clipboard.get_image()? (And how did you evaluate the return value?) Even if it works as advertised, we'd need a function to copy the current canvas to clipboard. (Why can't I even find that?) This is why I dread updates of my favorite apps.

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

                canvas.draw_clipboard(0,0,scrSize[0],scrSize[1]) lets you draw on a copied image. What's its inverse?

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

                  i think scene or ui is intended to be sort of a replacement to canvas. Although not as convienent for doing interactive "turtle" style drawings, these do let you save.

                  What you are asking is possible via the new objc module. The UIImageView that represents the canvas is a sibling to the console output textview. It should be possible to grab the UIImage reference, and use UIImagePNGRepresentation to write out the png. I don't have time this morning tomwork on it, but in the next day or so. In the meantime, check out scene drawing, or ui.Path style drawing, which I think have many of the features you want.

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

                    @JonB couldn't you just use ui.ImageView.draw_snapshot() as you recommended in https://forum.omz-software.com/topic/2185/image-from-scene ?

                    1 Reply Last reply Reply Quote 1
                    • brumm
                      brumm last edited by

                      Sorry, I think I mixed it up.

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

                        https://gist.github.com/389a67c5aacb097b87fd

                        Simply import this function, and run it after drawing to the canvas. see example.
                        It is not necessary to fill the canvas white- it is actually transparent, unless you have drawn to it (as should be obvious when you save an image then quickview it)

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