You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
846 B
Python

from PIL import Image
import PIL.ImageOps
#open both the image and watermark
image = Image.open('split/page1.png')
logo = Image.open('merged.png')
#rotate the watermark
rotatedlogo = logo.rotate(18, expand=True)
#invert the watermark
invertedlogo = PIL.ImageOps.invert(rotatedlogo)
invertedlogo.save('rotatedlogo.png')
#rescaling the logo
basewidth = 1050
finallogo = Image.open("rotatedlogo.png")
wpercent = (basewidth/float(finallogo.size[0]))
hsize = int((float(finallogo.size[1])*float(wpercent)))
finallogo = finallogo.resize((basewidth,hsize), Image.ANTIALIAS)
#overlaying
image_copy = image.copy()
#if you want to position in the bottom right corner use:
#position = ((image_copy.width - logo.width), (image_copy.height - logo.height))
position = ((100), (750))
image_copy.paste(finallogo, position)
image_copy.save('split/page1.png')