Skip to content

dlab-projects/headshots

 
 

Repository files navigation

Headshot Processing Tool

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.

Prerequisites

System Requirements

  • macOS (tested on macOS with Apple Silicon)
  • Python 3.9+
  • Homebrew package manager
  • ImageMagick

Installation Steps

  1. Install Homebrew (if not already installed):

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install ImageMagick:

    brew install imagemagick
  3. Install pipenv:

    python3 -m pip install --user pipenv

Setup

  1. Navigate to the headshots directory:

    cd headshots
  2. Install Python dependencies:

    pipenv install --dev

Usage

Local Processing

  1. Place your images in the input/ directory

  2. 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)
  3. Alternative shell script:

    ./mkheadshot.sh [input_dir] [gravity] [offset]

Output

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)

File Naming Convention

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

Google Apps Script Integration

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.

Cloud Function

The cloud-functions/ directory contains a Google Cloud Function that provides the same image processing capabilities via HTTP API.

Troubleshooting

Common Issues

  1. "MagickWand shared library not found":

    • Ensure ImageMagick is installed: brew install imagemagick
    • Set the MAGICK_HOME environment variable: export MAGICK_HOME="/opt/homebrew"
  2. "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"
  3. "brew: command not found":

    • Add Homebrew to PATH: export PATH="/opt/homebrew/bin:$PATH"
  4. Permission errors:

    • Ensure the script is executable: chmod +x mkheadshot.py mkheadshot.sh

File Processing Errors

  • 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

Dependencies

  • Python: wand (ImageMagick Python binding)
  • System: ImageMagick, Homebrew
  • Cloud: Flask, google-cloud-storage (for cloud function)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 55.3%
  • Python 30.5%
  • Shell 9.6%
  • Makefile 4.6%