Skip to content

Commit

Permalink
fix handling of large images
Browse files Browse the repository at this point in the history
  • Loading branch information
bunburya committed Feb 6, 2023
1 parent 53600cd commit fc2629e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bother_utils/heightmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ def crop_image(im: Image, width: int, height: int, mode: str) -> Image:
box[0] = (im.width - width) // 2
box[2] = box[0] + width


# Image.crop chokes on large images unless we increase the max size
size = width * height
if size > Image.MAX_IMAGE_PIXELS:
Image.MAX_IMAGE_PIXELS = size

return im.crop(box)

def scale_image(im: Image, width: int, height: int) -> Image:
Expand Down

0 comments on commit fc2629e

Please sign in to comment.