

def TrimImage(imagename):
    im = Image.open(imagename)
    idx = 0
    width = im.size[0]
    height = im.size[1]
    top = height
    bottom = 0
    left = width
    right = 0
    x = 0
    y = 0
    for pix in im.getdata():
        if (pix[3] != 0):
            if (top > y):
                top = y
            if (y < y):
                bottom = y
            if (left > x):
                left = x
            if (right < x):
                right = x
        x = (x + 1)
        if (x == width):
            x = 0
            y = (y + 1)
    box = (left, top, right, bottom)
    cropped = im.crop(box)
    cropped.load()
    return ((width, height), box, cropped)

dataset/ETHPy150Open kleientertainment/ds_mod_tools/pkg/unix/mod_tools/tools/scripts/pipelinetools.py TrimImage/VarMisuse@104/112 `bottom`->`y`