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.


    Smarter image resize

    Pythonista
    3
    3
    2608
    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.
    • pixeldynamo
      pixeldynamo last edited by

      I'm wondering if Pythonista could be used to solve a problem that thus far I've been unable to address with any of the image editing apps on the iTunes store.

      I need to be able to create images of a particular size, from a variety of source pictures with differing dimensions and aspect ratios.

      Tinkering with Image.resize, I can obviously convert any image to a specific size, but depending on the original dimensions/aspect ratio this will distort the result.

      Ideally, I would like to be able to read in the image size, check how this compares against my desired final sizing, resize the image down so that the width is no less than 692px and height at least 484px, then crop from the middle of the product to produce the final shot.

      I can't see any obvious way to do this using crop, or transform. Does anyone have any idea/suggestions on how to achieve the above?

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

        I would assume this is feasible using PIL's crop, see http://stackoverflow.com/questions/9983263/crop-the-image-using-pil-in-python.

        Otherwise, now that numpy is included in Pythonista, you could do the cropping using arrays, then convert back to an Image object.

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

          I wrote a script to keep the aspect ratio here. And here you can find a script to change the size of an camera roll image and to store it.

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