def rotate_image(filename, line, sdir, image_list):
    """Rotate a image.

    Given a filename and a line, figure out what it is that the author
    wanted to do wrt changing the rotation of the image and convert the
    file so that this rotation is reflected in its presentation.

    :param: filename (string): the name of the file as specified in the TeX
    :param: line (string): the line where the rotate command was found

    :output: the image file rotated in accordance with the rotate command
    :return: True if something was rotated
    """
    file_loc = get_image_location(filename, sdir, image_list)
    degrees = re.findall('(angle=[-\\d]+|rotate=[-\\d]+)', line)

    if len(degrees) < 1:
        return False

    degrees = degrees[0].split('=')[-1].strip()

    if file_loc is None or file_loc == 'ERROR' or\
            not re.match('-*\\d+', degrees):
        return False

    if degrees:
        try:
            degrees = int(degrees)
        except (ValueError, TypeError):
            return False

        if not os.path.exists(file_loc):
            return False

        with Image(filename=file_loc) as image:
            with image.clone() as rotated:
                rotated.rotate(degrees)
                rotated.save(filename=file_loc)
        return True
    return False
Rotate a image.

    Given a filename and a line, figure out what it is that the author
    wanted to do wrt changing the rotation of the image and convert the
    file so that this rotation is reflected in its presentation.

    :param: filename (string): the name of the file as specified in the TeX
    :param: line (string): the line where the rotate command was found

    :output: the image file rotated in accordance with the rotate command
    :return: True if something was rotated