mirror of
https://github.com/zulip/zulip.git
synced 2025-10-22 20:42:14 +00:00
thumbnail: Avoid BytesIO.getbuffer.
It seems to cause ‘BufferError: Existing exports of data: object cannot be re-sized’ on Python 3.13. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
committed by
Tim Abbott
parent
f9faad0997
commit
2ddafe728e
@@ -59,8 +59,9 @@ def ensure_thumbnails(image_attachment: ImageAttachment) -> int:
|
||||
return 0
|
||||
|
||||
written_images = 0
|
||||
image_bytes = BytesIO()
|
||||
save_attachment_contents(image_attachment.path_id, image_bytes)
|
||||
with BytesIO() as f:
|
||||
save_attachment_contents(image_attachment.path_id, f)
|
||||
image_bytes = f.getvalue()
|
||||
try:
|
||||
# TODO: We could save some computational time by using the same
|
||||
# bytes if multiple resolutions are larger than the source
|
||||
@@ -96,7 +97,7 @@ def ensure_thumbnails(image_attachment: ImageAttachment) -> int:
|
||||
else:
|
||||
load_opts = "n=1"
|
||||
resized = pyvips.Image.thumbnail_buffer(
|
||||
image_bytes.getbuffer(),
|
||||
image_bytes,
|
||||
thumbnail_format.max_width,
|
||||
height=thumbnail_format.max_height,
|
||||
option_string=load_opts,
|
||||
|
Reference in New Issue
Block a user