Commit 41f0e1ab authored by Amrita Deb's avatar Amrita Deb
Browse files

iss4 correction implemented

parent 1c295d09
......@@ -106,6 +106,25 @@ def create_watermark_template(img_file, matnum, dpi):
return template
def remove_transparency(im, bg_colour=(255, 255, 255)):
Correct transparent image turning black issue
pdf page image
background color white code
corrected image when the image is transparent
else just retuirn the pdf page image
if im.mode in ('RGBA', 'LA') or (im.mode == 'P' and 'transparency' in
alpha = im.convert('RGBA').split()[-1]
# Create a new background image of our matt color.
# Must be RGBA because paste requires both images have the same format
bg ="RGBA", im.size, bg_colour + (255,))
bg.paste(im, mask=alpha)
return bg
return im
def watermark_img(img_file, template, dpi):
"""Watermarks image with watermark template
......@@ -121,6 +140,7 @@ def watermark_img(img_file, template, dpi):
# Open image
image ='RGBA')
image = remove_transparency(image)
width, height = image.size
# Apply watermark
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment