dimtoneff / ComfyUI-PixelArt-Detector

Generate, downscale, change palletes and restore pixel art images with SDXL.
MIT License
174 stars 10 forks source link

Error occurred when executing PixelArtDetectorConverter: 'ImageDraw' object has no attribute 'textsize' #10

Closed HaydenReeve closed 8 months ago

HaydenReeve commented 9 months ago

The following error occurs when enabling the render_all_palettes_in_grid option and I'm not exactly sure why.

Perhaps someone could help by shedding some light on this one, thanks!

Error occurred when executing PixelArtDetectorConverter:

'ImageDraw' object has no attribute 'textsize'

File "E:\AI\ComfyUI\execution.py", line 153, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\execution.py", line 83, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\execution.py", line 76, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\custom_nodes\ComfyUI-PixelArt-Detector\PixelArtDetector.py", line 243, in process
PILOutput = self.genImagesForGrid(pilImage, paletteList)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\custom_nodes\ComfyUI-PixelArt-Detector\PixelArtDetector.py", line 275, in genImagesForGrid
drawTextInImage(img, annotation, fontSize, fontColor, strokeColor=gridBackground)
File "E:\AI\ComfyUI\custom_nodes\ComfyUI-PixelArt-Detector\pixelUtils.py", line 56, in drawTextInImage
text_width, text_height = draw.textsize(text, font)
^^^^^^^^^^^^^

image

dimtoneff commented 9 months ago

Yeah, they removed the textsize...

It's no longer called textsize, it's called textlength.

dimtoneff commented 9 months ago

image

Solution for now: PIL < 10.0

https://pillow.readthedocs.io/en/stable/releasenotes/9.5.0.html

I will check it out and do a fix soon

dimtoneff commented 9 months ago

Version 1.5 should be working with both <10 & >10 versions of Pillow. Please, test as I can only use v9.5 Pillow for now.

dimtoneff commented 8 months ago

Closing as completed. Please, reopen if any issues with the GRID.

HaydenReeve commented 8 months ago

Cheers, confirmed working on the original example with pillow 10.0.1