def parse_crop(cropstr):
    """
    Crop is provided as string, same as imagemagick:
        size_x, size_y, offset_x, offset_y, eg 10x10+30+30 would cut a 10x10 square at 30,30
    Output is the indices as would be used in a numpy array. In the example,
    [30,40,30,40] (ie [miny, maxy, minx, maxx])

    """
    split = cropstr.split("x")
    xsize = int(split[0])
    split = split[1].split("+")
    ysize = int(split[0])
    xoff = int(split[1])
    yoff = int(split[2])
    crop = [yoff, yoff+ysize, xoff, xoff+xsize]
    return crop