这篇文章主要介绍了python使用PIL模块实现给图片来源gaodai$ma#com搞$$代**码网打水印的方法,涉及使用PIL模块操作图片的相关技巧,需要的朋友可以参考下
本文实例讲述了python使用PIL模块实现给图片打水印的方法。分享给大家供大家参考。具体实现方法如下:
import Image, ImageEnhance def reduce_opacity(im, opacity): """Returns an image with reduced opacity.""" assert opacity >= 0 and opacity <= 1 if im.mode != 'RGBA': im = im.convert('RGBA') else: im = im.copy() alpha = im.split()[3] alpha = ImageEnhance.Brightness(alpha).enhance(opacity) im.putalpha(alpha) return im def watermark(im, mark, position, opacity=1): """Adds a watermark to an image.""" if opacity
希望本文所述对大家的Python程序设计有所帮助。
以上就是python使用PIL模块实现给图片打水印的方法的详细内容,更多请关注gaodaima搞代码网其它相关文章!