PEATDB/PILView.py
def doImageRescale(self, img, framew, frameh):
        """ensures that the image is displayed with the
           correct ratio as the frame is resized """   
        
        imgw, imgh = img.size
        imageratio = float(imgw)/float(imgh)
        print imageratio
        if (imageratio >= 1):
            w = framew
            h = int(w / imageratio)
            left=0
            top = frameh/2 - h/2            
            if (h > frameh):
                h = frameh
                w = int(h * imageratio)
                top=0
                left=framew/2 - w/2 
        elif (imageratio < 1):
            h = frameh
            w = int(h * imageratio)
            if (w > framew):
                w = framew
                h = int(w / imageratio)
            top=0    
            left = framew/2 - w/2 
        newimg = img.resize((w, h), Image.ANTIALIAS)        
        return newimg, top, left
ensures that the image is displayed with the
           correct ratio as the frame is resized 
ensures that the image is displayed with the
correct ratio as the frame is resized
ensures that the image is displayed with the correct ratio as the frame is resized
def doImageRescale(self, img, framew, frameh):
        imgw, imgh = img.size
        imageratio = float(imgw)/float(imgh)
        print imageratio
        if (imageratio >= 1):
            w = framew
            h = int(w / imageratio)
            left=0
            top = frameh/2 - h/2            
            if (h > frameh):
                h = frameh
                w = int(h * imageratio)
                top=0
                left=framew/2 - w/2 
        elif (imageratio < 1):
            h = frameh
            w = int(h * imageratio)
            if (w > framew):
                w = framew
                h = int(w / imageratio)
            top=0    
            left = framew/2 - w/2 
        newimg = img.resize((w, h), Image.ANTIALIAS)        
        return newimg, top, left
def doImageRescale ( self , img , framew , frameh ) : imgw , imgh = img . size imageratio = float ( imgw ) / float ( imgh ) print imageratio if ( imageratio >= 1 ) : w = framew h = int ( w / imageratio ) left = 0 top = frameh / 2 - h / 2 if ( h > frameh ) : h = frameh w = int ( h * imageratio ) top = 0 left = framew / 2 - w / 2 elif ( imageratio < 1 ) : h = frameh w = int ( h * imageratio ) if ( w > framew ) : w = framew h = int ( w / imageratio ) top = 0 left = framew / 2 - w / 2 newimg = img . resize ( ( w , h ) , Image . ANTIALIAS ) return newimg , top , left
ensures that the image is displayed with the
correct ratio as the frame is resized
ensures that the image is displayed with the correct ratio as the frame is resized
"""ensures that the image is displayed with the
           correct ratio as the frame is resized """
self
img
framew
frameh