jkulesza/peacock

Peacock.py breaks with monochrome images

Opened this issue · 0 comments

PIL automatically loads grayscale images in a different format from RGB images, annoyingly :/ If you feed in a grayscale image the script will break. I don't know if the C++ version also has this issue. I also don't know if there's any good reason to feed in a grayscale image in the first place. But at the very least the program should terminate gracefully :)

It's possible to check whether the image is grayscale after loading it like so:
isinstance(self.image.getpixel((0,0)), int)
For RGB images, self.image.getpixel will return three values in a tuple; for grayscale it will just return an int. I made a cursory attempt to convert it to RGB or just use the gray value three times when converting to colorblind versions, but it was kind of a pain, so I gave up. I don't think this script is actively maintained but I'm leaving this comment for documentation in case it breaks for someone else.