当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python Pgmagick emboss()用法及代码示例


emboss()函数是Pgmagick库中的内置函数,用于对图像进行压印,这意味着将替换图像的每个像素以提供3D效果。成功时该函数返回真实值。

用法:
emboss(radius)

参数:该函数接受上述和以下描述的单个参数:

  • radius:该参数存储半径,用于指定压花半径。

返回值:此函数返回添加了图像的Pgmagick对象。

输入图片:



范例1:

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

输出:

范例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 emboss() function 
im.emboss(4) 
  
# invoke write function along with filename 
im.write('1_b.png')

输出:




相关用法


注:本文由纯净天空筛选整理自sarthak_ishu11大神的英文原创作品 Pgmagick emboss() method – Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。