image resize question

Tim Arnold tim.arnold at sas.com
Thu Oct 18 14:56:39 EDT 2007


Hi, I'm using the Image module to resize PNG images from 300 to 100dpi for 
use in HTML pages, but I'm losing some vertical and horizontal lines in the 
images (usually images of x-y plots).

Here's what I do:
import Image
def imgResize(self,filename):
        img = Image.open(filename)
        dpi = img.info.get('dpi')
        if dpi and 295 < int(dpi[0]) < 305:
            wd = img.size[0]/3.0 #convert from 300dpi to 100dpi
            ht = img.size[1]/3.0
            newimg= img.resize((int(wd),int(ht)))
            newimg.save(filename)

imgResize('myimage.png')

Can someone point me to a better way so I don't lose the reference lines in 
the images?
thanks,
--Tim Arnold





More information about the Python-list mailing list