top of page

Smart Image Watermark Aligner


Smart Image Watermark Aligner
Smart Image Watermark Aligner

Definition


I tried to create a Python program for placing a consistent watermark mask in the bottom corners of images. This program finds the optimal bottom corner for the watermark in each image and then masks the watermark onto the images. The same watermark size, ratio and colour are masked onto each image. Upload the same watermark in two different colours, like black and white, for both light and dark images.


Operation


1| An image file is opened, copied and resized to a 1:1 square (1000 x 1000 pixels).

2| The square 1:1 copy is cropped twice in order to define each of the bottom corners.

3| The bottom corner images are sorted by brightness to determine the best corner to place the watermark.

4| A second copy of the original image is made, the watermark file is opened and then masked onto the second copy.

5| The watermarked second copy of the original image is saved.


Inspiration


I post a lot of images on social media that are manually watermarked. My logo watermark isn't always placed in the same size, opacity, color and position on images. From this, I was inspired to develop a Python program to consistently watermark large amounts of images. I'm not an expert at CPython so I experimented with image processing using Pillow. I learned a lot from this attempt and from my research on similar open-source programs.


Summary


Watermarking images automatically based outside the position of the subjects in images is very difficult. A more advanced code would probably struggle to operate this program and accurately watermark bulk image files.

bottom of page