PIL是Python Imaging Library,它為python解釋器提供了圖像編輯函數。 ImageOps模塊包含許多“現成的”圖像處理操作。該模塊有些實驗性,大多數操作員隻能處理L和RGB圖像。
ImageOps.expand()
在要調用或使用此函數的圖像上添加邊框。
用法:PIL.ImageOps.expand(image, border = 0, fill = 0)
參數:
image:圖像大小和裁剪。
border:要應用於圖像的邊框,以像素為單位。
fill:這定義了要應用的像素填充值或顏色值。默認值為0,表示顏色為黑色。
返回:帶有所需邊框的圖像。
下麵是執行ImageOps.expand()
使用的圖片:
# Importing Image and ImageOps module from PIL package
from PIL import Image, ImageOps
# creating a image1 object
im1 = Image.open(r"C:\Users\System-Pc\Desktop\a.jpg")
# applying expand method
# using border value = 20
# using fill = 50 which is brown type color
im2 = ImageOps.expand(im1, border = 20, fill = 50)
im2.show()
輸出:
相關用法
- Python next()用法及代碼示例
- Python os.dup()用法及代碼示例
- Python set()用法及代碼示例
- Python Decimal max()用法及代碼示例
- Python PIL ImageOps.fit()用法及代碼示例
- Python os.rmdir()用法及代碼示例
- Python sympy.det()用法及代碼示例
- Python Decimal min()用法及代碼示例
- Python os.readlink()用法及代碼示例
- Python os.writev()用法及代碼示例
- Python os.readv()用法及代碼示例
- Python PIL RankFilter()用法及代碼示例
- Python os.rename()用法及代碼示例
- Python os.sendfile()用法及代碼示例
注:本文由純淨天空篩選整理自Sunitamamgai大神的英文原創作品 Python PIL | ImageOps.expand() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。