Speedup code #3776
tonal
started this conversation in
Help wanted
Speedup code
#3776
Replies: 2 comments 3 replies
-
Hi @tonal, You probably don't need all the pre/unpre multiply. And I'm not sure what you are resizing. Could you post some sample input images and a desired result? |
Beta Was this translation helpful? Give feedback.
3 replies
-
This might do what you want: #!/usr/bin/env python3
import sys
import pyvips
def add_watermark(img_path, mark_path, size=(400, 400)):
img = pyvips.Image.new_from_file(str(img_path), access='sequential')
img = img.colourspace('srgb')
if not img.hasalpha():
img = img.addalpha()
img = img.gravity('centre', size[0], size[1])
imark = pyvips.Image.new_from_file(str(mark_path), access='sequential')
imark = imark.colourspace('srgb')
img = img.composite2(imark, 'over',
x=img.width - imark.width,
y=img.height - imark.height)
return img
img = add_watermark(sys.argv[1], sys.argv[2], size=(3000, 3000))
img.write_to_file(sys.argv[3]) So the image is centred within |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I need to place a reduced image on a transparent background and apply a watermark on top.
How to do it as quickly as possible?
Beta Was this translation helpful? Give feedback.
All reactions