2024-04-23 23:29:37 发布
网友
我想弄清楚如何创建这种水印,尤其是位于中间的水印(这不是广告,它只是我想要实现的完美示例):
你可以用libvips这样做:
https://gist.github.com/jcupitt/db972e738cfacdf8055f
这是将这篇博文直接翻译成Python:
http://libvips.blogspot.co.uk/2013/07/watermarking-with-ruby-vips.html
该要点的第一个块生成水印图像(只是一些重复的文本),如果愿意,可以将其替换为加载水印图像。在
我没有在我所在的地方安装python,但应该是这样的。在
import Image photo = Image.open("photo.jpg") watermark = Image.open("watermark.png") photo.paste(watermark, (0, 0), watermark) photo.save("photo_with_watermark.jpg")
Image.paste doc
Python的wand库有一个Image.watermark方法,可以简化常见的水印操作。在
from wand.image import Image with Image(filename='background.jpg') as background: with Image(filename='watermark.png') as watermark: background.watermark(image=watermark, transparency=0.75) background.save(filename='result.jpg')
你可以用libvips这样做:
https://gist.github.com/jcupitt/db972e738cfacdf8055f
这是将这篇博文直接翻译成Python:
http://libvips.blogspot.co.uk/2013/07/watermarking-with-ruby-vips.html
该要点的第一个块生成水印图像(只是一些重复的文本),如果愿意,可以将其替换为加载水印图像。在
我没有在我所在的地方安装python,但应该是这样的。在
Image.paste doc
Python的wand库有一个Image.watermark方法,可以简化常见的水印操作。在
相关问题 更多 >
编程相关推荐