Table of Contents
Shortcuts

# rotate

torchvision.transforms.functional.rotate(img: Tensor, angle: float, interpolation: InterpolationMode = InterpolationMode.NEAREST, expand: bool = False, center: Optional[List[int]] = None, fill: Optional[List[float]] = None) → Tensor

  Rotate the image by angle. If the image is torch Tensor, it is expected to have […, H, W] shape, where … means an arbitrary number of leading dimensions.

  Parameters:

    - img (PIL Image or Tensor) – image to be rotated.

    - angle (number) – rotation angle value in degrees, counter-clockwise.

    - interpolation (InterpolationMode) – Desired interpolation enum defined by `torchvision.transforms.InterpolationMode`. Default is `InterpolationMode.NEAREST`. If input is Tensor, only `InterpolationMode.NEAREST`, `InterpolationMode.BILINEAR` are supported. The corresponding Pillow integer constants, e.g. `PIL.Image.BILINEAR` are accepted as well.

    - expand (bool, optional) – Optional expansion flag. If true, expands the output image to make it large enough to hold the entire rotated image. If false or omitted, make the output image the same size as the input image. Note that the expand flag assumes rotation around the center and no translation.

    - center (sequence, optional) – Optional center of rotation. Origin is the upper left corner. Default is the center of the image.

    - fill (sequence or number, optional) –

      Pixel fill value for the area outside the transformed image. If given a number, the value is used for all bands respectively.

      Note

      In torchscript mode single int/float value is not supported, please use a sequence of length 1: `[value, ]`.

  Returns:

    Rotated image.

  Return type:

    PIL Image or Tensor

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.