This tool processes headshot images by resizing them to a standard 384x512 format and creating tessellated composite images. It includes both local processing scripts and cloud-based Google Apps Script integration.
- macOS (tested on macOS with Apple Silicon)
- Python 3.9+
- Homebrew package manager
- ImageMagick
-
Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -
Install ImageMagick:
brew install imagemagick
-
Install pipenv:
python3 -m pip install --user pipenv
-
Navigate to the headshots directory:
cd headshots -
Install Python dependencies:
pipenv install --dev
-
Place your images in the
input/directory -
Run the processing script:
pipenv run python mkheadshot.py
Or with custom parameters:
pipenv run python mkheadshot.py [input_dir] [gravity] [offset]
Parameters:
input_dir: Directory containing input images (default:./input)gravity: ImageMagick gravity setting (default:center)offset: ImageMagick offset setting (default:+0+0)
-
Alternative shell script:
./mkheadshot.sh [input_dir] [gravity] [offset]
The script creates two types of processed images:
- Normalized images (
normalized/directory): 384x512 pixel headshots - Tessellated images (
tessellated/directory): 768x512 pixel composites combining the headshot with the tessellation pattern (tess.png)
Note that the suffix added uses a double-underscore __ to make it easy to split on in scripts.
- Normalized:
{original_name}__384x512.png - Tessellated:
{original_name}__tessellated.png
The project also includes Google Apps Script files for cloud-based processing:
headshots__14eMn_pD1rlXPP13kDvF3VnptSfryvFRUyvYzTZgsPacGYFfLJiHYNW5_/: Production version../headshot-test__14eMn_pD1rlXPP13kDvF3VnptSfryvFRUyvYzTZgsPacGYFfL/: Test version
These scripts integrate with Google Sheets and Google Cloud Functions for automated processing.
The cloud-functions/ directory contains a Google Cloud Function that provides the same image processing capabilities via HTTP API.
-
"MagickWand shared library not found":
- Ensure ImageMagick is installed:
brew install imagemagick - Set the MAGICK_HOME environment variable:
export MAGICK_HOME="/opt/homebrew"
- Ensure ImageMagick is installed:
-
"pipenv: command not found":
- Install pipenv:
python3 -m pip install --user pipenv - Add to PATH:
export PATH="/Users/$(whoami)/Library/Python/3.9/bin:$PATH"
- Install pipenv:
-
"brew: command not found":
- Add Homebrew to PATH:
export PATH="/opt/homebrew/bin:$PATH"
- Add Homebrew to PATH:
-
Permission errors:
- Ensure the script is executable:
chmod +x mkheadshot.py mkheadshot.sh
- Ensure the script is executable:
- The script will skip non-image files (like
.DS_Store,.keep) with error messages - Supported image formats: JPEG, PNG, and other formats supported by ImageMagick
- Python:
wand(ImageMagick Python binding) - System: ImageMagick, Homebrew
- Cloud: Flask, google-cloud-storage (for cloud function)