#NEWLINE# def _get_thumbnail_image_from_file( dir_path , image_file ) : #NEWLINE# #INDENT# '\n    Get a PIL.Image from the given image file which has been scaled down to\n    THUMBNAIL_WIDTH wide.\n\n    @param {String} dir_path - The directory containing the image file\n\n    @param {String} image_file - The filename of the image file within dir_path\n\n    @return {PIL.Image} An instance of the thumbnail as a PIL Image, or None\n        if the functionality is not available. See _get_image_from_file for\n        details.\n    ' #NEWLINE# img = _get_image_from_file ( dir_path , image_file ) #NEWLINE# if ( img is None ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# if ( img . format . lower ( ) == 'gif' ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# ( img_width , img_height ) = img . size #NEWLINE# scale_ratio = ( THUMBNAIL_WIDTH / float ( img_width ) ) #NEWLINE# target_height = int ( ( scale_ratio * img_height ) ) #NEWLINE# try : #NEWLINE# #INDENT# img . thumbnail ( ( THUMBNAIL_WIDTH , target_height ) , resample = RESAMPLE ) #NEWLINE# #UNINDENT# except IOError as exptn : #NEWLINE# #INDENT# print ( ( 'WARNING: IOError when thumbnailing %s/%s: %s' % ( dir_path , image_file , exptn ) ) ) #NEWLINE# return None #NEWLINE# #UNINDENT# return img