1

How could I cut one image into other images using pillow if I have a given row and column.

For example if I have an image with a row = 4 and a column = 4, I need the image to be cut into 16 pieces. (4x4) The pieces all need to have the same size so I could fix that by adding a border to the image but I don't know how to do that with pillow.

Pseudocode will do!

Dries Coppens
  • 1,085
  • 9
  • 20
  • 1
    Cutting? See http://stackoverflow.com/q/6059217/2564301. Adding border? http://stackoverflow.com/q/11142851/2564301. Size for each tile? `(im.size[0] + column-1)//column`, and the same for `[1]` and `row`. – Jongware Apr 17 '16 at 14:37

1 Answers1

1
  1. Create a new image of the correct size and colour to act as a background.
  2. Paste the original image into it.
  3. Use crop to get your sub-rectangles.
PM 2Ring
  • 54,345
  • 6
  • 82
  • 182