Hướng dẫn pillow rotate image python
The Show
This article describes each parameter of
Please refer to the following article for installation and basic usage of Pillow(PIL).
Use
See the following article for image rotation with OpenCV, NumPy.
Load the images as follows:
Rotation angle: angleIn Rotate 90 degrees:
Rotate 45 degrees.
Resampling Filters: resampleThe parameter
With
Expand output image size: expandAs can be seen from the output image of the above example, by default, the size of the output image is equal to the size of the input image, and parts outside the region are truncated. If you want to keep the whole rotated image,
set the parameter
Coordinates of the center of rotation: centerYou can specify the rotation center position with the parameter
In the case of
Translation: translateYou can translate before rotation with the parameter Without rotation:
Rotate 45 degrees and translate:
If
Color for the outside area: fillcolorYou can specify the color for the outside area with the In the case of
RGB images, it is specified as a tuple of |