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')
====================================
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to