To add watermarks to images in batches, you can use image processing tools or software that support batch operations. These tools allow you to apply a watermark to multiple images simultaneously, saving time and effort. Here’s how it works and an example:
Using Python’s Pillow library:
from PIL import Image, ImageDraw, ImageFont
import os
def add_watermark(input_folder, output_folder, watermark_text):
if not os.path.exists(output_folder):
os.makedirs(output_folder)
font = ImageFont.load_default()
for filename in os.listdir(input_folder):
if filename.endswith(('.png', '.jpg', '.jpeg')):
img_path = os.path.join(input_folder, filename)
img = Image.open(img_path)
draw = ImageDraw.Draw(img)
# Position and style the watermark
text_width, text_height = draw.textsize(watermark_text, font=font)
x = img.width - text_width - 10
y = img.height - text_height - 10
draw.text((x, y), watermark_text, fill=(255, 255, 255, 128), font=font)
output_path = os.path.join(output_folder, filename)
img.save(output_path)
# Example usage
add_watermark('input_images', 'output_images', 'My Watermark')
For cloud-based solutions, Tencent Cloud’s Image Processing Service (IPS) can be used. It supports batch image operations, including adding watermarks, through its API or console. You can upload images to a COS (Cloud Object Storage) bucket and use IPS to apply watermarks in bulk, automating the process for large-scale image management.