DECIMER/config.py
def central_square_image(im):
    """
    This function takes a Pillow Image object and will add white padding
    so that the image has a square shape with the width/height of the longest side
    of the original image.
    ___
    im: PIL.Image
    ___
    output: PIL.Image
    """
    max_wh = int(1.2 * max(im.size))
    # If the new image is smaller than 299x299, then let's paste it into an empty image
    # of that size instead of distorting it later while resizing.
    if max_wh < 299:
        max_wh = 299
    new_im = Image.new(im.mode, (max_wh, max_wh), "white")
    paste_pos = (
        int((new_im.size[0] - im.size[0]) / 2),
        int((new_im.size[1] - im.size[1]) / 2),
    )
    new_im.paste(im, paste_pos)
    return new_im

    This function takes a Pillow Image object and will add white padding
    so that the image has a square shape with the width/height of the longest side
    of the original image.
    ___
    im: PIL.Image
    ___
    output: PIL.Image
    
This function takes a Pillow Image object and will add white padding
so that the image has a square shape with the width/height of the longest side
of the original image.
This function takes a Pillow Image object and will add white padding so that the image has a square shape with the width / height of the longest side of the original image .
def central_square_image(im):
    max_wh = int(1.2 * max(im.size))
    if max_wh < 299:
        max_wh = 299
    new_im = Image.new(im.mode, (max_wh, max_wh), "white")
    paste_pos = (
        int((new_im.size[0] - im.size[0]) / 2),
        int((new_im.size[1] - im.size[1]) / 2),
    )
    new_im.paste(im, paste_pos)
    return new_im
def central_square_image ( im ) : max_wh = int ( 1.2 * max ( im . size ) ) if max_wh < 299 : max_wh = 299 new_im = Image . new ( im . mode , ( max_wh , max_wh ) , "white" ) paste_pos = ( int ( ( new_im . size [ 0 ] - im . size [ 0 ] ) / 2 ) , int ( ( new_im . size [ 1 ] - im . size [ 1 ] ) / 2 ) , ) new_im . paste ( im , paste_pos ) return new_im
This function takes a Pillow Image object and will add white padding
so that the image has a square shape with the width/height of the longest side
of the original image.
This function takes a Pillow Image object and will add white padding so that the image has a square shape with the width / height of the longest side of the original image .
"""
    This function takes a Pillow Image object and will add white padding
    so that the image has a square shape with the width/height of the longest side
    of the original image.
    ___
    im: PIL.Image
    ___
    output: PIL.Image
    """ # If the new image is smaller than 299x299, then let's paste it into an empty image # of that size instead of distorting it later while resizing.
im