<s> try : <EOL> from cStringIO import cStringIO as BytesIO <EOL> except ImportError : <EOL> from django . utils . six import BytesIO <EOL> try : <EOL> from PIL import Image <EOL> except ImportError : <EOL> import Image <EOL> from easy_thumbnails import utils <EOL> def pil_image ( source , exif_orientation = True , ** options ) : <EOL> """<STR_LIT>""" <EOL> if not source : <EOL> return <EOL> source = BytesIO ( source . read ( ) ) <EOL> image = Image . open ( source ) <EOL> try : <EOL> image . load ( ) <EOL> except IOError : <EOL> pass <EOL> image . load ( ) <EOL> if exif_orientation : <EOL> image = utils . exif_orientation ( image ) <EOL> return image </s>
