# Path: image_filer/utils/pil_exif.py
# def get_exif(im):
#     try:
#         exif_raw = im._getexif() or {}
#     except:
#         return {}
#     ret={}
#     for tag, value in exif_raw.items():
#         decoded = ExifTags.TAGS.get(tag, tag)
#         ret[decoded] = value
#     return ret
# 
# def get_subject_location(exif_data):
#     try:
#         r = ( int(exif_data['SubjectLocation'][0]), int(exif_data['SubjectLocation'][1]), )
#     except:
#         r = None
#     return r


    import Image
    import ImageColor
    import ImageFile
    import ImageFilter
    import ImageEnhance
    import ImageDraw
    import ExifTags
        from PIL import Image
        from PIL import ImageColor
        from PIL import ImageFile
        from PIL import ImageFilter
        from PIL import ImageEnhance
        from PIL import ImageDraw
        from PIL import ExifTags
from image_filer.utils.pil_exif import get_exif, get_subject_location
try:
except ImportError:
    try:
    except ImportError:
        raise ImportError("The Python Imaging Library was not found.")
        
def scale_and_crop(im, requested_size, opts, subject_location=None):
    x, y   = [float(v) for v in im.size]
    xr, yr = [float(v) for v in requested_size]
    
    # we need to extract exif data now, because after the first transition
    # the exif info is lost:
    exif_data = get_exif(im)
    
    if 'crop' in opts or 'max' in opts:
        r = max(xr/x, yr/y)

# Path: image_filer/utils/pil_exif.py
# def get_exif(im):
#     try:
#         exif_raw = im._getexif() or {}
#     except:
#         return {}
#     ret={}
#     for tag, value in exif_raw.items():
#         decoded = ExifTags.TAGS.get(tag, tag)
#         ret[decoded] = value
#     return ret
# 
# def get_subject_location(exif_data):
#     try:
#         r = ( int(exif_data['SubjectLocation'][0]), int(exif_data['SubjectLocation'][1]), )
#     except:
#         r = None
#     return r


# Path: image_filer/utils/sorl_filters.py
    import Image
    import ImageColor
    import ImageFile
    import ImageFilter
    import ImageEnhance
    import ImageDraw
    import ExifTags
        from PIL import Image
        from PIL import ImageColor
        from PIL import ImageFile
        from PIL import ImageFilter
        from PIL import ImageEnhance
        from PIL import ImageDraw
        from PIL import ExifTags
from image_filer.utils.pil_exif import get_exif, get_subject_location

try:
except ImportError:
    try:
    except ImportError:
        raise ImportError("The Python Imaging Library was not found.")
        
def scale_and_crop(im, requested_size, opts, subject_location=None):
    x, y   = [float(v) for v in im.size]
    xr, yr = [float(v) for v in requested_size]
    
    # we need to extract exif data now, because after the first transition
    # the exif info is lost:
    exif_data = get_exif(im)
    
    if 'crop' in opts or 'max' in opts:
        r = max(xr/x, yr/y)

    else: