This directory contains utility scripts for webmaster tasks at the Institute for Experimental Particle Physics (ETP) at Karlsruhe Institute of Technology (KIT).
Pads images to a target aspect ratio while preserving the original image quality and metadata.
Purpose: Useful for preparing images for the website where consistent aspect ratios are needed (e.g., profile photos, gallery images).
Usage:
python pad_imgs.py <image_path>Example:
python pad_imgs.py photo.jpg
# Output: photo_pad.jpgFeatures:
- Default aspect ratio: 2:3 (portrait orientation, needed for newsboxes on the homepage)
- Preserves EXIF orientation data
- Maintains ICC color profiles
- High-quality output (95% quality for JPEG, optimized compression)
- Smart white padding that adapts to image mode (RGB, RGBA, grayscale)
- Automatic format detection and preservation
- Centers the original image within the padded canvas
Supported Formats:
- JPEG
- PNG
- Other PIL-supported image formats
Requirements:
- Python 3.x
- Pillow (PIL)
Installation:
pip install PillowWhen adding new utility scripts to this directory, please update this README with:
- Script name and description
- Usage instructions
- Requirements
- Examples
For questions or issues related to these scripts, contact the ETP webmaster.