Add text watermarks to PDF files and images from the command line.
Supported input types:
- PDF:
.pdf - Images:
.jpg,.jpeg,.png,.bmp,.tif,.tiff,.webp
watermark_tool.py: core Python CLIrun_watermark.ps1: Windows wrapper (creates/activates.venv, checks dependencies, runs script, deactivates)run_watermark_linux: Linux wrapper (same behavior as PowerShell wrapper)requirements.txt: Python dependencies
- Python 3.8+
Run through the wrapper:
powershell -NoProfile -ExecutionPolicy Bypass -File .\run_watermark.ps1 "input.pdf" "output.pdf" --text "CONFIDENTIAL"Image example:
powershell -NoProfile -ExecutionPolicy Bypass -File .\run_watermark.ps1 "photo.jpg" "photo_marked.jpg" --text "SAMPLE" --position center --opacity 0.25Make wrapper executable once:
chmod +x ./run_watermark_linuxRun:
./run_watermark_linux input.pdf output.pdf --text "CONFIDENTIAL" --position tileImage example:
./run_watermark_linux photo.jpg photo_marked.jpg --text "SAMPLE" --position center --opacity 0.25Install dependencies:
python -m pip install -r requirements.txtRun:
python watermark_tool.py input.pdf output.pdf --text "CONFIDENTIAL" --position tile
python watermark_tool.py photo.jpg photo_marked.png --text "SAMPLE" --mode image --angle 30 --color "#00AAFF"Show help:
python watermark_tool.py --helpwatermark_tool.py input output --text TEXT [--mode auto|pdf|image] [--font-size N] [--opacity 0..1] [--color #RRGGBB] [--angle DEG] [--position center|tile|top-left|top-right|bottom-left|bottom-right] [--margin N] [--font-path PATH]
input: input file pathoutput: output file path--text: watermark text (required)--mode:auto(default),pdf, orimage--font-size: font size (default:48)--opacity: transparency from0to1(default:0.2)--color: hex color (default:#DC0000)--angle: rotation angle in degrees (default:35)--position:center,tile,top-left,top-right,bottom-left,bottom-right(default:tile)--margin: margin for corner positions (default:36)--font-path: optional custom TTF/TTC font path (image mode)
- In
--mode auto, the tool detects PDF vs image from input extension. - PDF watermarking uses
pypdf+reportlab. - Image watermarking uses
Pillow. - For JPG/JPEG/BMP output, the image is saved as RGB.
- If output folder does not exist, it is created automatically.
- Missing package error: run
python -m pip install -r requirements.txt - PowerShell policy error on Windows: use the wrapper with
-ExecutionPolicy Bypass - Unknown input extension in
automode: set--mode pdfor--mode image