I am a Software Developer @Andela. I listen to music in my free time and frequently squeeze in an episode of One Piece. I am also the creator of Memeke (http://meme.co.ke).
Location
Nairobi
Education
Moringa School, Mobile Applications Developer Certificate.
Traceback (most recent call last):
File "image.py", line 28, in
draw.text((x, y), message, fill=color, font=font)
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageDraw.py", line 213, in text
ink, fill = self._getink(fill)
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageDraw.py", line 111, in _getink
ink = self.palette.getcolor(ink)
File "/usr/local/lib/python2.7/dist-packages/PIL/ImagePalette.py", line 107, in getcolor
self.palette[index+256] = color[1]
IndexError: bytearray index out of range
Looks like you don't have fonts installed on your system. I missed this step in the post. The way Pillow works is that it builds on top of the fonts installed in the system. To fix the errors you are getting please install the fonts by following:
I am a Software Developer @Andela. I listen to music in my free time and frequently squeeze in an episode of One Piece. I am also the creator of Memeke (http://meme.co.ke).
Location
Nairobi
Education
Moringa School, Mobile Applications Developer Certificate.
Traceback (most recent call last):
File "image.py", line 28, in
draw.text((x, y), message, fill=color, font=font)
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageDraw.py", line 213, in text
ink, fill = self._getink(fill)
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageDraw.py", line 111, in _getink
ink = self.palette.getcolor(ink)
File "/usr/local/lib/python2.7/dist-packages/PIL/ImagePalette.py", line 107, in getcolor
self.palette[index+256] = color[1]
IndexError: bytearray index out of range
Thanks Morris,
Looks like you don't have fonts installed on your system. I missed this step in the post. The way Pillow works is that it builds on top of the fonts installed in the system. To fix the errors you are getting please install the fonts by following:
Ubuntu: How to install fonts on Ubuntu
For macOS and Windows just open the fonts files which you have downloaded.
Thanks for the response Vinay Jain. I will try installing the Roboto font and see if it works. Again, thanks for the help.