I have a method that takes a list of strings, a width, and a height and draws them using PIL. For small to medium lists this works perfectly. For large lists it crashes with this rather opaque exception:
Traceback (most recent call last): File "square-code.py", line 252, in <module> obj.main(sys.argv[1:]) File "square-code.py", line 98, in main self.render(lines, self.width, self.height) File "square-code.py", line 109, in render draw.text((x,y),line,font=font,fill=(0,0,0)) File "/usr/lib64/python2.6/site-packages/PIL/ImageDraw.py", line 263, in text mask, offset = font.getmask2(text, self.fontmode) File "/usr/lib64/python2.6/site-packages/PIL/ImageFont.py", line 151, in getmask2 self.font.render(text, im.id, mode=="1") IOError: unknown freetype error I've tried a couple different fonts and that doesn't make much difference. Image size also doesn't appear to matter. For example, with a 2600x2000 image if I write ~250 lines with ~650 characters each it works fine (font size 6). If I try to write ~950 lines with ~1300 characters each (font size 2) I get the crash above. I'd appreciate any insight into what might be going wrong, things I can do differently, or how to debug the problem. My method looks like this: def render(self, lines, width, height): im = Image.new('RGB',(width,height),(0xff,0xff,0xff)) draw = ImageDraw.Draw(im) font = self.get_font(self.font_size) x = 0 y = 0 for line in lines: draw.text((x,y),line,font=font,fill=(0,0,0)) y += font.getsize(line)[1] if os.path.splitext(self.ofile)[1] == '': self.ofile += ".png" im.save(self.ofile) Python 2.6, PIL 1.1.7
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig