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.
22 lines
622 B
Python
22 lines
622 B
Python
4 years ago
|
from PIL import Image
|
||
|
import os
|
||
|
|
||
|
filepath = 'page1.png'
|
||
|
basewidth, height = Image.open(filepath).size
|
||
|
basenumber, ext1 = os.path.splitext(str(basewidth*0.6))
|
||
|
base = int(basenumber)
|
||
|
|
||
|
#rescaling the logo
|
||
|
finallogo = Image.open("rotated.png")
|
||
|
wpercent = (base/float(finallogo.size[0]))
|
||
|
hsize = int((float(finallogo.size[1])*float(wpercent)))
|
||
|
finallogo = finallogo.resize((base,hsize), Image.ANTIALIAS)
|
||
|
|
||
|
finallogo.save('rotatedwatermark.png')
|
||
|
|
||
|
background = Image.open("page1.png")
|
||
|
foreground = Image.open('rotatedwatermark.png')
|
||
|
|
||
|
background.paste(foreground, (40, 70), foreground.convert('RGBA'))
|
||
|
background.save("page1.png")
|