#NEWLINE# def create_size( self , photosize ) : #NEWLINE# #INDENT# if self . size_exists ( photosize ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# im = Image . open ( self . image . storage . open ( self . image . name ) ) #NEWLINE# #UNINDENT# except IOError : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# im_format = im . format #NEWLINE# if ( self . effect is not None ) : #NEWLINE# #INDENT# im = self . effect . pre_process ( im ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( photosize . effect is not None ) : #NEWLINE# #INDENT# im = photosize . effect . pre_process ( im ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( 'Image Orientation' in self . EXIF ( ) ) and ( self . EXIF ( ) . get ( 'Image Orientation' ) . values [ 0 ] in IMAGE_EXIF_ORIENTATION_MAP ) ) : #NEWLINE# #INDENT# im = im . transpose ( IMAGE_EXIF_ORIENTATION_MAP [ self . EXIF ( ) . get ( 'Image Orientation' ) . values [ 0 ] ] ) #NEWLINE# #UNINDENT# if ( ( im . size != photosize . size ) and ( photosize . size != ( 0 , 0 ) ) ) : #NEWLINE# #INDENT# im = self . resize_image ( im , photosize ) #NEWLINE# #UNINDENT# if ( photosize . watermark is not None ) : #NEWLINE# #INDENT# im = photosize . watermark . post_process ( im ) #NEWLINE# #UNINDENT# if ( self . effect is not None ) : #NEWLINE# #INDENT# im = self . effect . post_process ( im ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( photosize . effect is not None ) : #NEWLINE# #INDENT# im = photosize . effect . post_process ( im ) #NEWLINE# #UNINDENT# #UNINDENT# im_filename = getattr ( self , ( 'get_%s_filename' % photosize . name ) ) ( ) #NEWLINE# try : #NEWLINE# #INDENT# buffer = BytesIO ( ) #NEWLINE# if ( im_format != 'JPEG' ) : #NEWLINE# #INDENT# im . save ( buffer , im_format ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# im . save ( buffer , 'JPEG' , quality = int ( photosize . quality ) , optimize = True ) #NEWLINE# #UNINDENT# buffer_contents = ContentFile ( buffer . getvalue ( ) ) #NEWLINE# self . image . storage . save ( im_filename , buffer_contents ) #NEWLINE# #UNINDENT# except IOError as e : #NEWLINE# #INDENT# if self . image . storage . exists ( im_filename ) : #NEWLINE# #INDENT# self . image . storage . delete ( im_filename ) #NEWLINE# #UNINDENT# raise e