def _scale_image(img, maxLen, maxHeight):
    ' scale image to under the specified maxLen and maxHeight '
    scale = 1
    resized_img = img.copy()
    if (resized_img.size[0] > maxLen):
        resize = (resized_img.size[0] / maxLen)
        answer = (int((resized_img.size[0] / resize)), int((resized_img.size[1] / resize)))
        scale = resize
        resized_img = resized_img.resize(answer, Image.ANTIALIAS)
    if (resized_img.size[1] > maxHeight):
        resize = (resized_img.size[1] / maxHeight)
        answer = (int((resized_img.size[0] / resize)), int((resized_img.size[1] / resize)))
        scale = (scale * resize)
        resized_img = resized_img.resize(answer, Image.ANTIALIAS)
    return (resized_img, scale)
scale image to under the specified maxLen and maxHeight
def _scale_image(img, maxLen, maxHeight):
    '  '
    scale = 1
    resized_img = img.copy()
    if (resized_img.size[0] > maxLen):
        resize = (resized_img.size[0] / maxLen)
        answer = (int((resized_img.size[0] / resize)), int((resized_img.size[1] / resize)))
        scale = resize
        resized_img = resized_img.resize(answer, Image.ANTIALIAS)
    if (resized_img.size[1] > maxHeight):
        resize = (resized_img.size[1] / maxHeight)
        answer = (int((resized_img.size[0] / resize)), int((resized_img.size[1] / resize)))
        scale = (scale * resize)
        resized_img = resized_img.resize(answer, Image.ANTIALIAS)
    return (resized_img, scale)