PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities.
PIL.Image.Image.paste() method is used to paste an image on another image. This is where the new() method comes in handy.
Syntax: PIL.Image.Image.paste(image_1, image_2, box=None, mask=None)
OR image_object.paste(image_2, box=None, mask=None)
image_1/image_object : It the image on which other image is to be pasted.
image_2: Source image or pixel value (integer or tuple).
box: An optional 4-tuple giving the region to paste into. If a 2-tuple is used instead, it’s treated as the upper left corner. If omitted or None, the source is pasted into the upper left corner.
If an image is given as the second argument and there is no third, the box defaults to (0, 0), and the second argument is interpreted as a mask image.
mask: An optional mask image.
PIL.Image.Image.rotate() method –
This method is used to rotate a given image to the given number of degrees counter clockwise around its centre.
new_object = PIL.Image.Image.rotate(image_object, angle, resample=0, expand=0)
new_object = image_object.rotate(angle, resample=0, expand=0)
Either of the syntax can be used
image_object: It is the real image which is to be rotated.
angle: In degrees counter clockwise.
resample: An optional resampling filter. This can be one of PIL.Image.NEAREST (use nearest neighbor), PIL.Image.BILINEAR (linear interpolation in a 2×2 environment), or PIL.Image.BICUBIC (cubic spline interpolation in a 4×4 environment). If omitted, or if the image has mode “1” or “P”, it is set PIL.Image.NEAREST.
expand: 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.
Return Value: Returns a copy of rotated image.
Images used –
- Python | Copy and Paste Images onto other Image using Pillow
- Python PIL | logical_and() and logical_or() method
- Python PIL | ImageChops.subtract() and ImageChops.subtract_modulo() method
- Python PIL | ImageEnhance.Color() and ImageEnhance.Contrast() method
- Python PIL | ImageChops.screen() and ImageChops.offset() method
- Python PIL | MedianFilter() and ModeFilter() method
- Python PIL | getbands() and getextrema() method
- Python PIL | MinFilter() and MaxFilter() method
- Python PIL | ImageChops.add_modulo() and ImageChops.difference() method
- Python PIL | ImageEnhance.Brightness() and ImageEnhance.Sharpness() method
- Python PIL | logical_xor() and invert() method
- Python PIL | GaussianBlur() method
- Python PIL | Kernel() method
- Python PIL | BoxBlur() method
- Python PIL | getbands() method
- Python PIL | ImageChops.subtract() method
- Python PIL | UnsahrpMask() method
- Python PIL | Image.crop() method
- Python PIL | ImageOps.expand() method
- Python PIL | ImageGrab.grabclipboard() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.