[Image-SIG] resizing an image with alphachannel: dirty edges
Ivan Elchin
ivangermes at gmail.com
Thu Nov 12 13:59:24 CET 2009
I have a problem, when i resizing an image with alphachannel.
Source image: http://dl.dropbox.com/u/932658/sega.png
Result image has dirty edges: http://dl.dropbox.com/u/932658/rez.png
Sample code code from Django Photologue):
====================================
import Image
im = Image.open("sega.png")
cur_width, cur_height = im.size
new_width, new_height = (200, 200)
if not new_width == 0 and not new_height == 0:
ratio = min(float(new_width)/cur_width,
float(new_height)/cur_height)
else:
if new_width == 0:
ratio = float(new_height)/cur_height
else:
ratio = float(new_width)/cur_width
new_dimensions = (int(round(cur_width*ratio)),
int(round(cur_height*ratio)))
new_im = im.resize(new_dimensions, Image.ANTIALIAS)
new_im.save('rez.png')
====================================
More information about the Image-SIG
mailing list