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


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


contrast()函数是Pgmagick库中的内置函数,用于增强或降低图像的对比度。成功时该函数返回真实值。

用法:
contast(multiplier)

参数:此函数接受单个参数乘数,该乘数是图像对比度应增加或减小的因数。

返回值:此函数返回添加了图像的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 contrast() function 
img.contrast(27) 
  
# 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 contrast() function 
im.contrast(40)  
  
# invoke write function along with filename 
im.write('1_b.png')

输出:




相关用法


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