PDA

View Full Version : Python and Images Weirdness



HalfEmptyHero
February 11th, 2010, 01:59 AM
I was testing out using python to resize images, and something really strange happened. I image I was using was a png image with a transparent background that came from a jpeg picture I had taken and edited. When I resized the image, the background came back, but I don't know how this is possible. If I open the same picture in gimp, there is no background and only one layer like there should be. Why did this happen and how can I stop it. This is the code I was using



import image
im1 = Image.open("image.png")
im2 = im1.resize((128, 128), Image.ANTIALIAS)
im2.save("image.png")