Dries Coppens
Dries Coppens

Reputation: 1085

Pillow cutting image

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!

Upvotes: 1

Views: 895

Answers (1)

PM 2Ring
PM 2Ring

Reputation: 55469

  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.

Upvotes: 1

Related Questions