#NEWLINE# def write_image( self , image ) : #NEWLINE# #INDENT# stream = image . stream #NEWLINE# filters = stream . get_filters ( ) #NEWLINE# if ( ( len ( filters ) == 1 ) and ( filters [ 0 ] in LITERALS_DCT_DECODE ) ) : #NEWLINE# #INDENT# ext = '.jpg' #NEWLINE# data = stream . get_rawdata ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( stream . colorspace is LITERAL_DEVICE_RGB ) : #NEWLINE# #INDENT# ext = '.bmp' #NEWLINE# data = create_bmp ( stream . get_data ( ) , ( stream . bits * 3 ) , image . width , image . height ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( stream . colorspace is LITERAL_DEVICE_GRAY ) : #NEWLINE# #INDENT# ext = '.bmp' #NEWLINE# data = create_bmp ( stream . get_data ( ) , stream . bits , image . width , image . height ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ext = '.img' #NEWLINE# data = stream . get_data ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# name = ( image . name + ext ) #NEWLINE# path = os . path . join ( self . outdir , name ) #NEWLINE# fp = file ( path , 'wb' ) #NEWLINE# fp . write ( data ) #NEWLINE# fp . close ( ) #NEWLINE# return name