2 Commits
main ... py3.12

Author SHA1 Message Date
Panchovix
ab9c2e2b27 Fix XYZ grid with Pillow >=10.0.0 2025-07-30 21:33:17 -04:00
Panchovix
4fbf54acd0 Add Python 3.12 support
Just updated some reqs as it is done on reForge. Tested quickly some XL models and seem to work so far.

Testers are welcome.
2025-07-27 18:26:53 -04:00
2 changed files with 17 additions and 6 deletions

View File

@@ -13,6 +13,8 @@ import numpy as np
import piexif
import piexif.helper
from PIL import Image, ImageFont, ImageDraw, ImageColor, PngImagePlugin, ImageOps
from PIL import __version__ as pillow_version
from pkg_resources import parse_version
# pillow_avif needs to be imported somewhere in code for it to work
import pillow_avif # noqa: F401
import string
@@ -168,9 +170,18 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts, margin=0):
for line in lines:
fnt = initial_fnt
fontsize = initial_fontsize
while drawing.multiline_textsize(line.text, font=fnt)[0] > line.allowed_width and fontsize > 0:
fontsize -= 1
fnt = get_font(fontsize)
if parse_version(pillow_version) >= parse_version('10.0.0'):
# New code for Pillow 10.0.0+
text_width, text_height = drawing.multiline_textbbox((0, 0), line.text, font=fnt)[2:]
while text_width > line.allowed_width and fontsize > 0:
fontsize -= 1
fnt = get_font(fontsize)
text_width, text_height = drawing.multiline_textbbox((0, 0), line.text, font=fnt)[2:]
else:
# Old code for Pillow versions below 10.0.0
while drawing.multiline_textsize(line.text, font=fnt)[0] > line.allowed_width and fontsize > 0:
fontsize -= 1
fnt = get_font(fontsize)
drawing.multiline_text((draw_x, draw_y + line.size[1] / 2), line.text, font=fnt, fill=color_active if line.is_active else color_inactive, anchor="mm", align="center")
if not line.is_active:

View File

@@ -1,8 +1,8 @@
setuptools==69.5.1 # temp fix for compatibility with some old packages
GitPython==3.1.32
Pillow==9.5.0
Pillow==10.4.0
accelerate==0.31.0
blendmodes==2022
blendmodes==2024.1.1
clean-fid==0.1.35
diskcache==5.6.3
einops==0.4.1
@@ -14,7 +14,7 @@ inflection==0.5.1
jsonmerge==1.8.0
kornia==0.6.7
lark==1.1.2
numpy==1.26.2
numpy==1.26.4
omegaconf==2.2.3
open-clip-torch==2.20.0
piexif==1.1.3