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.


    Cropping an image in Cards.py

    Pythonista
    2
    3
    2207
    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.
    • inoddy
      inoddy last edited by

      I want to crop the images used in the Cards.py example. But I can't figure out how.

      Do I do it in the line

      card.card_image = images[i]

      or the line

      card.image = card.card_image

      and if so then how?

      I've tried everything I can think of: Image.crop, ImageOps.crop, card.crop, card.card_image.crop, card.image.crop, images[i].crop but I appear to be missing something

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

        From the docs, Layer.image takes a filename, not an actual image.
        So you can't do any of the operations you tried, unless you load the file yourself as a PIL image, crop it, then write the file somewhere that you can read it.

        If you use scene.image(name, x=0, y=0, w=0, h=0[, from_x, from_y, from_w, from_h]) rather than the built in Layer property to draw your image, the from_x etc parameters handle cropping. No doubt that complicates things.

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

          Thanks for the suggestions. In the end I decided to use the first method. A little slow but it worked.

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