import random


def random_shift_image(pillow_image, max_width, max_height):
    """
    Randomly shifts the image width randomly with in [-max_width, max_width] and the
    height within the range [-max_height, max_height] adding black space at the edges.
    :param pillow_image: The image to shift
    :param max_width: The maximum amount to shift left or right.
    :param max_height: The maximum height to shift up or down.
    :return: Shifted image.
    """
    dx = random.randint(max_width * -1, max_width)
    dy = random.randint(max_height * -1, max_height)
    return pillow_image.crop((dx, dy, pillow_image.size[0] + dx, pillow_image.size[1] + dy))