kylefox/placeholder-pics

Basic use example generates errors

COLABORATI opened this issue · 1 comments

This error is produced by the "Basic use" example:

Traceback (most recent call last):
  File "./gen-pix.py", line 6, in <module>
    placeholder.image.save('12000.png')
  File "/home/xxx/.pyenv/versions/2.7.12/lib/python2.7/site-packages/placeholder_pics/placeholder.py", line 64, in image
    font = ImageFont.truetype(font=self.font_file, size=self.font_size)
  File "/home/xxx/.pyenv/versions/2.7.12/lib/python2.7/site-packages/PIL/ImageFont.py", line 259, in truetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/home/xxx/.pyenv/versions/2.7.12/lib/python2.7/site-packages/PIL/ImageFont.py", line 143, in __init__
    self.font = core.getfont(font, size, index, encoding, layout_engine=layout_engine)
IOError: cannot open resource

Looks like something is assumed that is true only on your computer. I guess that I have to define some font file path somewhere, however it would be nice if the script had no assumptions about the world that make a basic two line example fail.

Looks like there is no font file in the package that was installed via pip. I do not know enough about python packages to fix that in a minute, sorry.

I didn't know how to fix it either, but after some research it appears using package_data and pkg_resources.resource_filename to install & load the file is the correct approach. 5dbad62

Fixed in v1.0.3