daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def save( self ):
  2.          
  3.         #picture = request.FILES['picture']
  4.         #self.picture.save( name=self.picture.name, content=picture, save=False )                                                                
  5.          
  6.         thumb = Image.open( self.picture.path )
  7.         ext   = thumb.format
  8.          
  9.         if thumb.mode not in( 'L', 'RGB' ):
  10.             thumb = thumb.convert( 'RGB' )
  11.         thumb.thumbnail( THUMB_SIZE, Image.ANTIALIAS)
  12.          
  13.         fp = StringIO( )
  14.         thumb.save( fp, ext )
  15.          
  16.         if self.thumb:
  17.            os.remove( self.thumb.path )
  18.          
  19.         cf = ContentFile( fp.getvalue( ))
  20.         self.thumb.save( name=self.picture.name, content=cf, save=False )
  21.          
  22.         super( Pixeldonor, self ).save( )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top