def create_and_store_thumb(self, image, thumb_name, thumb_options):
        """
        Given that 'image' is a PIL Image object, create a thumbnail for the
        given size tuple and store it via the storage backend.
        
        image: (Image) PIL Image object.
        size: (tuple) Tuple in form of (width, height). Image will be
            thumbnailed to this size.
        """
        size = thumb_options['size']
        upscale = thumb_options.get('upscale', True)
        crop = thumb_options.get('crop')
        if crop is True:
            # We'll just make an assumption here. Center cropping is the
            # typical default.
            crop = 'center'

        thumb_filename = self._calc_thumb_filename(thumb_name)
        file_extension = self.get_thumbnail_format()

        # The work starts here.
        thumbed_image = THUMBNAIL_ENGINE.create_thumbnail(
            image,
            size,
            crop=crop,
            upscale=upscale
        )

        # TODO: Avoiding hitting the disk here, but perhaps we should use temp
        # files down the road? Big images might choke us as we do part in
        # RAM then hit swap.
        img_fobj = cStringIO.StringIO()
        # This writes the thumbnailed PIL.Image to the file-like object.
        THUMBNAIL_ENGINE.write(thumbed_image, img_fobj, format=file_extension)
        # Save the result to the storage backend.
        thumb_content = ContentFile(img_fobj.getvalue())
        self.storage.save(thumb_filename, thumb_content)
        img_fobj.close()
def create_and_store_thumb ( self , image , thumb_name , thumb_options ) : size = thumb_options [ 'size' ] upscale = thumb_options . get ( 'upscale' , True ) crop = thumb_options . get ( 'crop' ) if crop is True : crop = 'center' thumb_filename = self . _calc_thumb_filename ( thumb_name ) file_extension = self . get_thumbnail_format ( ) thumbed_image = THUMBNAIL_ENGINE . create_thumbnail ( image , size , crop = crop , upscale = upscale ) img_fobj = cStringIO . StringIO ( ) THUMBNAIL_ENGINE . write ( thumbed_image , img_fobj , format = file_extension ) thumb_content = ContentFile ( img_fobj . getvalue ( ) ) self . storage . save ( thumb_filename , thumb_content ) img_fobj . close ( )
Given that 'image' is a PIL Image object, create a thumbnail for the
        given size tuple and store it via the storage backend.
        
        image: (Image) PIL Image object.
        size: (tuple) Tuple in form of (width, height). Image will be
            thumbnailed to this size.