def update_exif_for_rotated_image(exif):
    """Modifies the Exif tag if rotation has been performed.

    0th, 1st
    --------
    ImageWidth = 256
    ImageLength = 257
    XResolution = 282
    YResolution = 283
    TileWidth = 322
    TileLength = 323

    Exif
    ----
    PixelXDimension = 40962
    PixelYDimension = 40963

    Args:
        exif (dict): The parsed Exif tag

    Returns:
        The modified Exif dict.

    """
    orientation_value = exif.get('0th', ).get(
        piexif.ImageIFD.Orientation, exif.get('1st', ).get(
            piexif.ImageIFD.Orientation, None))

    if orientation_value is not None:
        # Update orientation.
        exif['0th'][piexif.ImageIFD.Orientation] = 1
        if exif.get('1st', {}).get(piexif.ImageIFD.Orientation) is not None:
            exif['1st'][piexif.ImageIFD.Orientation] = 1

        # If 90 or 270 degree rotation, x dimensions are now y dimensions,
        # so flip all such properties.
        if orientation_value > 4:
            for exif_tag in ['0th', '1st']:
                if exif.get(exif_tag) is not None:
                    x, y = (exif.get(exif_tag).get(piexif.ImageIFD.ImageWidth),
                            exif.get(exif_tag).get(piexif.ImageIFD.ImageLength))
                    if x is not None and y is not None:
                        exif[exif_tag][piexif.ImageIFD.ImageWidth] = y
                        exif[exif_tag][piexif.ImageIFD.ImageLength] = x

                    x, y = (exif.get(exif_tag).get(piexif.ImageIFD.XResolution),
                            exif.get(exif_tag).get(piexif.ImageIFD.YResolution))
                    if x is not None and y is not None:
                        exif[exif_tag][piexif.ImageIFD.XResolution] = y
                        exif[exif_tag][piexif.ImageIFD.YResolution] = x

                    x, y = (exif.get(exif_tag).get(piexif.ImageIFD.TileWidth),
                            exif.get(exif_tag).get(piexif.ImageIFD.TileLength))
                    if x is not None and y is not None:
                        exif[exif_tag][piexif.ImageIFD.TileWidth] = y
                        exif[exif_tag][piexif.ImageIFD.TileLength] = x
            if exif.get('Exif') is not None:
                x, y = (exif.get('Exif').get(piexif.ExifIFD.PixelXDimension),
                        exif.get('Exif').get(piexif.ExifIFD.PixelYDimension))
                if x is not None and y is not None:
                    exif['Exif'][piexif.ExifIFD.PixelXDimension] = y
                    exif['Exif'][piexif.ExifIFD.PixelYDimension] = x
        if exif.get('thumbnail') is not None:
            try:
                thumbnail = pil_open(io.BytesIO(exif.get('thumbnail')))
                thumbnail = autorotate(thumbnail, orientation=orientation_value)
                with io.BytesIO() as bio:
                    thumbnail.save(bio, format='jpeg')
                    bio.seek(0)
                    exif['thumbnail'] = bio.read()
            except Exception as e:
                warnings.warn("deprecated", DeprecationWarning)

    return exif
Modifies the Exif tag if rotation has been performed.

    0th, 1st
    --------
    ImageWidth = 256
    ImageLength = 257
    XResolution = 282
    YResolution = 283
    TileWidth = 322
    TileLength = 323

    Exif
    ----
    PixelXDimension = 40962
    PixelYDimension = 40963

    Args:
        exif (dict): The parsed Exif tag

    Returns:
        The modified Exif dict.