當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Python Pgmagick spread()用法及代碼示例


spread()函數是Pgmagick庫中的內置函數,用於將圖像像素移位任意數量。成功時該函數返回真實值。

用法:
spread(thresholdLevel)

參數:該函數接受上述和以下所述的兩個參數:

返回值:此函數返回添加了圖像的Pgmagick對象。

Input Image:



範例1:

from pgmagick import Image, DrawableCircle, DrawableText 
from pgmagick import Geometry, Color 
  
# draw the image of dimension 600 * 600 
img = Image('input.png') 
  
# invoke spread function with factor as 5 
img.spread(5) 
  
# invoke write function along with filename 
img.write('2_a.png')

Output:

範例2:

# import library 
from pgmagick import Image, DrawableCircle, DrawableText 
from pgmagick import Geometry, Color 
  
# Draw image of dimension 600 * 600 having background green 
im = Image(Geometry(600, 600), Color("# 32CD32")) 
  
# invoke DrawableCircle() function 
circle = DrawableCircle(100, 100, 300, 20) 
  
# invoke draw() function 
im.draw(circle) 
  
# set font size to 40px 
im.fontPointsize(40) 
  
# invoke DrawableText() function 
text = DrawableText(250, 450, "GeeksForGeeks") 
  
# invoke draw() function 
im.draw(text) 
  
# invoke spread function with factor as 4 
im.spread(4) 
  
# invoke write function along with filename 
im.write('1_b.png')

Output:




相關用法


注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 Pgmagick spread() method – Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。