def _create_image_thumbnail(file_path, longest_side=settings.THUMBNAIL_SIZE, pad=False):
 original_image = Image.open(file_path)
 original_image = original_image.convert('RGBA')
 (file_width, file_height) = original_image.size
 (width, height) = _scale_dimensions(file_width, file_height, longest_side)
 resized_image = original_image.resize((width, height), Image.ANTIALIAS)
 io = StringIO.StringIO()
 if pad:
  padded_image = _make_image_square(resized_image, longest_side)
  padded_image.save(io, 'PNG')
 else:
  resized_image.save(io, 'PNG')
 return ContentFile(io.getvalue())

def _create_image_thumbnail ( file_path , longest_side = settings . THUMBNAIL_SIZE , pad = False ) : original_image = Image . open ( file_path ) original_image = original_image . convert ( 'RGBA' ) ( file_width , file_height ) = original_image . size ( width , height ) = _scale_dimensions ( file_width , file_height , longest_side ) resized_image = original_image . resize ( ( width , height ) , Image . ANTIALIAS ) io = StringIO . StringIO ( ) if pad : padded_image = _make_image_square ( resized_image , longest_side ) padded_image . save ( io , 'PNG' ) else : resized_image . save ( io , 'PNG' ) return ContentFile ( io . getvalue ( ) )
returns a thumbnail file with a set longest side .