GitHunt

TUI Photo Booth

ASCII art photo booth for your terminal. Capture photos from your webcam and render them as ASCII art with adjustable effects.

                                                      
     ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄      
    ▐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▌     
    ▐░█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█░▌     
    ▐░█  TUI PHOTO BOOTH                     █░▌     
    ▐░█  > Press [Space] to capture          █░▌     
    ▐░█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█░▌     
    ▐░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▌     
     ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀      

Features

  • Webcam Capture - Take photos directly from your terminal
  • Half-Block Rendering - 2x vertical resolution using Unicode half-block characters ()
  • True Color Support - Full RGB color mode for terminals that support it
  • Real-time Adjustments - Brightness, contrast, and gamma sliders
  • Effects - Invert colors, edge enhancement
  • Export - Save as JPG + ASCII art (.txt) or ANSI art (.ans) with native file picker
  • Countdown Timer - 3-2-1 countdown with large ASCII numbers

Prerequisites

System Requirements

  • macOS (uses imagesnap for webcam capture, AppleScript for save dialog)
  • Bun v1.0 or later
  • True color terminal (iTerm2, Kitty, Alacritty, Warp, etc.)

Install Dependencies

  1. Install Bun (if not already installed):

    curl -fsSL https://bun.sh/install | bash
  2. Install imagesnap for webcam capture:

    brew install imagesnap
  3. Verify imagesnap works:

    imagesnap -l  # List available cameras

Installation

git clone https://github.com/YOUR_USERNAME/tui-photobooth.git
cd tui-photobooth
bun install

Usage

bun start

Or in watch mode for development:

bun dev

Controls

Key Action
Space Take photo / Retake
Tab Cycle through sliders
Shift+Tab Cycle backwards through sliders
Adjust selected slider
H Toggle half-block mode (2x resolution)
C Toggle color mode (when in half-block mode)
I Toggle invert
E Toggle edge enhancement
S Save/export (opens native file picker)
Q Quit

How It Works

Image Capture

Uses imagesnap CLI to capture frames from the webcam. The camera has a 1-second warmup delay to ensure proper exposure.

ASCII Conversion

  1. Image Processing - Uses sharp to resize, flip (mirror), and apply brightness/contrast/gamma adjustments
  2. Character Mapping - Maps pixel brightness to ASCII characters: .-:=+*#%@
  3. Half-Block Mode - Uses the character with different foreground/background colors to represent 2 vertical pixels per character cell, effectively doubling vertical resolution

Color Rendering

  • Grayscale Mode - Maps brightness to 8 quantized gray levels for efficient batching
  • Color Mode - Uses ANSI 24-bit true color escape codes (\x1b[38;2;R;G;Bm for foreground, \x1b[48;2;R;G;Bm for background)

Export Formats

  • JPG - Original captured image
  • TXT - Plain ASCII art (standard ASCII mode)
  • ANS - ANSI art with embedded escape codes (half-block mode) - can be viewed with cat file.ans

Tech Stack

Project Structure

src/
├── index.tsx          # Entry point, app setup
├── AsciiCamera.tsx    # Main component, UI, keyboard handling
├── asciiConverter.ts  # Image → ASCII/half-block conversion
├── capturePhoto.ts    # Webcam capture via imagesnap
├── Slider.tsx         # Slider UI component
└── hooks.ts           # Custom React hooks

Troubleshooting

"imagesnap not found"

Install it with Homebrew:

brew install imagesnap

Camera not working

  1. Check available cameras: imagesnap -l
  2. Grant terminal app camera permissions in System Settings → Privacy & Security → Camera

Colors look wrong

Make sure your terminal supports true color (24-bit). Test with:

printf "\x1b[38;2;255;100;0mTRUE COLOR\x1b[0m\n"

If you see orange text, your terminal supports true color.

Save dialog not appearing

The save feature uses AppleScript which requires macOS. Make sure your terminal has Automation permissions in System Settings.

License

MIT License - do whatever you want with it.