"Cannot filter palette images" when executing ImageEnhance.Sharpness ()

I have a GIF image file. I opened it with help PIL.Imageand made several size conversions on it. Then I tried to use ImageSharpness.Enhance()on it ...

sharpener = PIL.ImageEnhance.Sharpness(img)
sharpened = sharpener.enhance(2.0)

This throws an exception:

<type 'exceptions.ValueError'>
('cannot filter palette images',)

I tried google for this error but found nothing. Can someone help me figure out what is going wrong?

FYI input image mode 'P'. I do not have this problem if I work with jpg images.

+5
source share
1 answer
sharpener = PIL.ImageEnhance.Sharpness (img.convert('RGB'))

, . convert , RGB .

+7

All Articles