rrwick / Trycycler

A tool for generating consensus long-read assemblies for bacterial genomes
GNU General Public License v3.0
306 stars 28 forks source link

textsize deprecated in Pillow 10, causes error "'ImageDraw' object has no attribute 'textsize'" in dotplot.py #72

Closed erikwolfsohn closed 6 months ago

erikwolfsohn commented 7 months ago

Hi! On Trycycler 0.5.4 installed via conda, dotplot.py fails with the error 'ImageDraw' object has no attribute 'textsize' It looks like textsize was deprecated in Pillow 10 and superseded by textlength. Installing into a fresh environment via the Trycycler conda recipe provided Pillow 10.2.0 by default.

I think there shouldn't be any issues downgrading Pillow, but I just replaced each instance of text_width, text_height = draw.textsize(label, font=font) with

text_width = draw.textlength(label, font=font) text_height = draw.textlength(label, font=font) and it seemed to work fine.

It also seems like the new textlength method returns floats by default while 'textsize' returned ints which will cause another crash. I just changed the type in the return statement like so return font, int(text_width), int(text_height), font_size which doesn't appear to be causing issues. I don't know if that new method could potentially return fractional values that would produce mangled results though.

Also just want to say I really appreciate this tool and really appreciate the incredibly detailed guidance and documentation you've written to accompany it - I'm beginning to work with long read data regularly and this has been an unbelievable resource.

rrwick commented 6 months ago

Thanks for pointing this one out - the fix is in the latest release of Trycycler (v0.5.5) which is now on Bioconda.

Ryan