I\'m getting about the same bad looking resizing from all the 4 algorithms of PIL
>>> data = utils.fetch(\"http://wavestock.com/images/beta-ico
The image posted is an indexed image. Its mode is 'P'
if you read it via PIL. The PIL documentation on Image.resize() for the resample parameter states that:
If the image has mode “1” or “P”, it is always set to PIL.Image.NEAREST
So PIL will use nearest filter for resizing indexed images, which is a low quality filter.
The right way is to convert the image mode to RGB
and then use resize with a high-quality filter such as Image.LANCZOS
. By the way, Image.ANTIALIAS
is now the same as Image.LANCZOS
, source here.
import Image
img = Image.open("beta-icon.gif").convert("RGB")
img = img.resize((36,36), Image.LANCZOS)
img.save("img-resized.png")