I've added Chandan's scaling funtion to util Called by scaled = util.scale_rectangle_to_max((2304, 3072), (100, 200))
def scale_rectangle_to_max(size, max_size): ''' returns a scaled rectangle size fitting the size to max_size this can be used to scale images for viewing in a browser and retaining the aspect ratio ''' try: scaled_width = max_size[0] scaled_height = max_size[1] # if actual image aspect ratio > scaled image aspect ratio then scale height if float(size[0]) / size[1] > float(scaled_width) / scaled_height: scaled_height = scaled_width * size[1] / size[0] else: # else scale width scaled_width = scaled_height * size[0] / size[1] except ZeroDivisionError: pass return (scaled_width, scaled_height) This can be used to scale an image when the full image is opened in the browser, keeping the aspect ratio. May be this should really by kaa.imlib2 Duncan ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Freevo-devel mailing list Freevo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freevo-devel