Answer the question
In order to leave comments, you need to log in
What is the OSError: cannot identify image file error when applying a watermark to an image?
What is the OSError: cannot identify image file error when applying a watermark to an image?
from PIL import Image as PImage
def watermark_photo(self, input_image_path, output_image_path, watermark_image_path, position):
base_image = PImage.open(input_image_path)
base_image = base_image.convert('RGB')
watermark = PImage.open(watermark_image_path)
width, height = base_image.size
transparent = PImage.new('RGBA', (width, height), (0,0,0,0))
transparent.paste(base_image, (0,0))
transparent.paste(watermark, position, mask=watermark)
transparent.show()
transparent.save(output_image_path)
Answer the question
In order to leave comments, you need to log in
look at what you have in input_image_path and is it possible to open this file?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question