Python PIL | ImageOps.expand() method
Last Updated :
16 Sep, 2021
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. the ImageOps module contains a number of ‘ready-made’ image processing operations. This module is somewhat experimental, and most operators only work on L and RGB images.
ImageOps.expand() adds a border to the image upon which this function is called or used.
Syntax: PIL.ImageOps.expand(image, border = 0, fill = 0)
Parameters:
image : The image to size and crop.
border : The border to be applied to the image in pixels.
fill: This defines the pixel fill value or color value to be applied. The default value is 0 which means the color is black.
Returns: An image with the required border.
Below is the implementation of ImageOps.expand()
Image used:
Python3
from PIL import Image, ImageOps
im1 = Image. open (r "C:\Users\System-Pc\Desktop\a.jpg" )
im2 = ImageOps.expand(im1, border = 20 , fill = 50 )
im2.show()
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...