From afc0e8e1a0791ecc67fb34aa824607a71ea9d4a9 Mon Sep 17 00:00:00 2001 From: REDxEYE Date: Sat, 13 Aug 2022 23:43:44 +0300 Subject: [PATCH] Fix mipmap calculation --- src/PIL/VtfImagePlugin.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/PIL/VtfImagePlugin.py b/src/PIL/VtfImagePlugin.py index 58019bea1..76d8a002e 100644 --- a/src/PIL/VtfImagePlugin.py +++ b/src/PIL/VtfImagePlugin.py @@ -178,10 +178,9 @@ def _get_mipmap_count(width: int, height: int): while True: mip_width = width >> mip_count mip_height = height >> mip_count - if mip_width < 1 or mip_height < 1: - break + if mip_width == 0 and mip_height == 0: + return mip_count mip_count += 1 - return mip_count def _write_image(fp: BufferedIOBase, im: Image.Image, pixel_format: VtfPF):