In Python, Python Image Library 1.1.6, how can I expand the canvas without resizing?

前端 未结 4 943
北恋
北恋 2020-12-05 18:42

I am probably looking for the wrong thing in the handbook, but I am looking to take an image object and expand it without resizing (stretching/squishing) the original image.

4条回答
  •  天命终不由人
    2020-12-05 18:42

    You might consider a rather different approach to your image... build it out of tiles of a fixed size. That way, as you need to expand, you just add new image tiles. When you have completed all of your computation, you can determine the final size of the image, create a blank image of that size, and paste the tiles into it. That should reduce the amount of copying you're looking at for completing the task.

    (You'd likely want to encapsulate such a tiled image into an object that hid the tiling aspects from the other layers of code, of course.)

提交回复
热议问题