(self, degrees, clockwise=False, resample_algorithm=nearest, resize_canvas=True)
return self._copy(pixels)
Returns the image obtained by rotating this image by the
        given number of degrees.
        Anticlockwise unless clockwise=True is given.
Returns the image obtained by rotating this image by the
        given number of degrees.
        Anticlockwise unless clockwise=True is given.
Returns the image obtained by rotating this image by the given number of degrees . Anticlockwise unless clockwise = True is given .
def rotate(self, degrees, clockwise=False, resample_algorithm=nearest, resize_canvas=True):
        """
        Returns the image obtained by rotating this image by the
        given number of degrees.
        Anticlockwise unless clockwise=True is given.
        """
        # translate to the origin first, then rotate, then translate back
        transform = AffineTransform()
        transform = transform.translate(self.width * -0.5, self.height * -0.5)
        transform = transform.rotate(degrees, clockwise=clockwise)

        width, height = self.width, self.height
        if resize_canvas:
            # determine new width
            width, height = get_transformed_dimensions(transform, (0, 0, width, height))

        transform = transform.translate(width * 0.5, height * 0.5)

        pixels = resample_algorithm.affine(self, transform, resize_canvas=resize_canvas)

        return self._copy(pixels)
def rotate ( self , degrees , clockwise = False , resample_algorithm = nearest , resize_canvas = True ) : # translate to the origin first, then rotate, then translate back transform = AffineTransform ( ) transform = transform . translate ( self . width * - 0.5 , self . height * - 0.5 ) transform = transform . rotate ( degrees , clockwise = clockwise ) width , height = self . width , self . height if resize_canvas : # determine new width width , height = get_transformed_dimensions ( transform , ( 0 , 0 , width , height ) ) transform = transform . translate ( width * 0.5 , height * 0.5 ) pixels = resample_algorithm . affine ( self , transform , resize_canvas = resize_canvas ) return self . _copy ( pixels )