Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def annotate_img(image, service, layers, environ, query_extent, **kw):
- # Required opacity of watermark
- opacity = float(0.5)
- # Get path to watermark png
- wm_path = Image.open(os.path.join(os.path.dirname(__file__), 'watermark_256.png'))
- # Grab tile and Convert to RGBA
- img = image.as_image()
- if img.mode != 'RGBA':
- img = img.convert('RGBA')
- # Create new RGBA image for watermark
- wm = Image.new('RGBA', img.size, (0,0,0,0))
- wm.paste(wm_path)
- # Adjust opacity of watermark
- alpha = wm.split()[3]
- alpha_c = ImageEnhance.Brightness(alpha).enhance(opacity)
- wm.putalpha(alpha_c)
- # Create new composite image using the wm as a mask
- compo = Image.composite(wm, img, wm)
- final_img = Image.new('RGBA', img.size, (0,0,0,0))
- final_img.paste(compo)
- return ImageSource(final_img, image.image_opts)
- self.im.paste(im, box)
- ValueError: images do not match
- self.im.paste(im, box, im)
Add Comment
Please, Sign In to add comment