Image Processing Scripts
Image Processing Scripts
These scripts help manage images in the Jekyll site, particularly for removing gray borders that appear when converting SVGZ files (from Wacom stylus drawings) to PNG format.
Scripts
1. process-images.sh
Automatically converts SVGZ files to PNG and removes uniform borders from images.
Features:
- Converts all SVGZ files to high-quality PNG
- Removes gray (or any uniform color) borders using ImageMagickβs trim function
- Preserves original files
- Creates processed versions in
_processed_imagessubdirectories - Also checks existing PNG files for borders
- Skips specified files that should keep their borders (e.g., StuGantt.png)
Usage:
./scripts/process-images.sh
Requirements:
- ImageMagick (
convertcommand) - librsvg (
rsvg-convertcommand)
Installation:
# Ubuntu/Debian
sudo apt-get install imagemagick librsvg2-bin
# Arch Linux
sudo pacman -S imagemagick librsvg
# macOS
brew install imagemagick librsvg
2. update-image-references.sh
Updates all image references in markdown and HTML files to use the processed (border-free) versions.
Usage:
# Dry run - see what would change
./scripts/update-image-references.sh --dry-run
# Apply changes
./scripts/update-image-references.sh
Workflow
- Create your SVGZ files using your Wacom stylus workflow
- Run
./scripts/process-images.shto create border-free versions - Run
./scripts/update-image-references.shto update all references - Commit both the original and processed images
Example
Before processing:
assets/battcock/
βββ gr-qc.svgz # Original SVGZ with gray border
βββ gr-qc.png # PNG with gray border
After processing:
assets/battcock/
βββ gr-qc.svgz # Original SVGZ (preserved)
βββ gr-qc.png # Original PNG (preserved)
βββ _processed_images/
βββ gr-qc.png # Border-free version
References updated from:
\
To:
\
Notes
- Original files are never modified
- The trim function removes any border that matches the corner pixel colors
- A 5% fuzz factor is used to handle slight color variations
- High-resolution conversion (2000px width) maintains image quality
- Some files are exempt from processing (like StuGantt.png) because their borders are deliberate
- To add more exempt files, edit the SKIP_FILES array in
process-images.shEOF < /dev/null