def imgCrop(image, cropBox, boxScale=1):
    """
    Crop a PIL image with the provided box 

    :param image: the PIL image to be cropped
    :param cropBox: a list containing the dimensions of the box in 
    [x(left), y(upper), w(width), h(height)] format
    :param boxScale: an optional scaling factor for the crop box
    :returns: the cropped image
    """

    # Calculate scale factors
    xDelta = max(cropBox[2] * (boxScale - 1), -10000)
    yDelta = max(cropBox[3] * (boxScale - 1), -10000)

    # Convert cv box to PIL box [left, upper, right, lower]
    PIL_box = [cropBox[0] - xDelta, cropBox[1] - yDelta, cropBox[0] +
               cropBox[2] + xDelta, cropBox[1] + cropBox[3] + yDelta]

    return image.crop(PIL_box)