def new_size_by_croping_ratio(original_size, target_size, crop_type='center'):
    """Return a tuple of top-left and bottom-right points (x1, y1, x2, y2) coresponding
    to a crop of the original size keeping the same aspect ratio of the target size.

    Note: target_size is only used to calculate aspect ratio, the returned coordinates
          doesn't fit to it.

    The position of the rectangle can be defined by the crop_type parameter:

       * top-left
       * top-center
       * top-right
       * center-left
       * center
       * center-right
       * bottom-left
       * bottom-center
       * bottom-right
    """
    # Get current and desired ratio for the images
    img_ratio = original_size[0] / float(original_size[1])
    ratio = target_size[0] / float(target_size[1])

    tx, ty = original_size
    if ratio > img_ratio:
        # crop on constant width
        ty = int(original_size[0] / ratio)
    elif ratio < img_ratio:
        # crop on constant height
        tx = int(ratio * original_size[1])

    x, y = 0, 0
    if crop_type.endswith('left'):
        x = 0
    elif crop_type.endswith('center'):
        x = (original_size[0] - tx) // 2
    elif crop_type.endswith('right'):
        x = original_size[0] - tx

    if crop_type.startswith('top'):
        y = 0
    elif crop_type.startswith('center'):
        y = (original_size[1] - ty) // 2
    elif crop_type.startswith('bottom'):
        y = original_size[1] - ty

    return (x, y, tx + x, ty + y)