Skip to content

Commit

Permalink
image_wall: backup fit method
Browse files Browse the repository at this point in the history
  • Loading branch information
dale-wahl committed Jul 11, 2024
1 parent eeb1dde commit 0b57457
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions processors/visualisation/image_wall.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ def numpy_to_rgb(numpy_array):
if sort_mode not in ("", "random") and (picture.height > sample_max or picture.width > sample_max):
sample_width = int(sample_max * picture.width / max(picture.width, picture.height))
sample_height = int(sample_max * picture.height / max(picture.width, picture.height))
picture = ImageOps.fit(picture, (sample_width, sample_height))
try:
picture = ImageOps.fit(picture, (sample_width, sample_height))
except ValueError:
# Default of BICUBIC may fail
picture = ImageOps.fit(picture, (sample_width, sample_height), method=Image.NEAREST)

if sort_mode not in ("", "random"):
# ensure we get RGB values for pixels
Expand Down Expand Up @@ -354,9 +358,14 @@ def numpy_to_rgb(numpy_array):

if tile_x == -1:
picture_x = max(1, int(picture.width * (tile_y / picture.height)))
picture = ImageOps.fit(picture, (picture_x, tile_y), method=Image.BILINEAR)
else:
picture = ImageOps.fit(picture, (tile_x, tile_y), method=Image.BILINEAR)
picture_x = tile_x

try:
picture = ImageOps.fit(picture, (picture_x, tile_y), method=Image.BILINEAR)
except ValueError:
# BILINEAR may also fail
picture = ImageOps.fit(picture, (picture_x, tile_y), method=Image.NEAREST)

# simply put them side by side until the right edge is reached,
# then move to a new row
Expand Down

0 comments on commit 0b57457

Please sign in to comment.