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.


    too many load_pil_image calls?

    Pythonista
    3
    4
    2739
    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.
    • guyhillyer163
      guyhillyer163 last edited by

      Hi, this code https://gist.github.com/4191121 tries to dynamically build up an image and display it at each step. It calls load_pil_image once for every invocation of Scene.draw. I'm guessing this is too much, because pythonista crashes after a short while. Is there a better way to do something like this? Is there a way to unload a loaded image?

      Thanks

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

        There's currently no way to unload images loaded via load_pil_image, though it's probably a very good idea to add something like that.

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

          I think it would be better if it was implemented like this:

          # Instantiate PIL image object into pythonista
          imgObj = load_pil_image(...)
          
          image(imgObj, x, y, w, h) # x, y, w, h could be a Rect called bounds instead
          # OR
          imgObj.draw(x, y, w, h)
          
          # Release the used resources of the image object
          del imgObj
          

          The same should be done for all image loading mechanisms, not just PIL ones.

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

            Yes, probably. The PIL integration for the scene module was kind of an after-thought and using strings had some advantages at first (mostly being easier for novice users).

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