B
B
bQ12019-07-16 16:55:18
Django
bQ1, 2019-07-16 16:55:18

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)

The error is indicated on the line: base_image = PImage.open(input_image_path)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Guest007, 2019-07-16
@bQ1

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 question

Ask a Question

731 491 924 answers to any question