-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed as not planned
Description
Image resizing errors on Pillow v.10.4.0, while it ran smoothly in older versions (10.3.0, 9.3.0).
Sample Code
from io import BytesIO
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
from PIL.Image import Resampling
def create_test_image():
file = BytesIO()
image = Image.new('RGBA', size=(50, 50), color=(155, 0, 0))
image.save(file, 'png')
file.name = 'test.png'
file.seek(0)
return file
source_file = create_test_image()
fig, ax = plt.subplots()
wm = Image.open(source_file)
wm_size = np.array(wm.size)
max_size = fig.get_size_inches() * fig.dpi * 0.6 # NOQA
scaling_factor = min(max_size / wm_size)
img_size = (wm_size * scaling_factor).astype(int)
wmr = wm.resize(img_size, Resampling.LANCZOS)Error Log
Traceback (most recent call last):
...
File "...\scratches\scratch.py", line 26, in
wmr = wm.resize(img_size, Resampling.LANCZOS)
File "...\anaconda3\envs\dev\lib\site-packages\PIL\Image.py", line 2297, in resize
if self.size == size and box == (0, 0) + self.size:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
What are your OS, Python and Pillow versions?
- OS: Windows 11 Pro / Gitlab Servers
- Python: 3.10.8
- Pillow: 10.4.0