This file provides guidance to WARP (warp.dev) when working with code in this repository.
Pixelpop is a terminal utility library for displaying and animating images, GIFs, and photo sequences with ANSI color support. It's an ES module library written in TypeScript that provides both static image rendering and animated GIF playback in terminal environments.
npm run build # Compile TypeScript to dist/
npm run clean # Remove dist directorynpm run lint # Run ESLint
npm run lint:fix # Run ESLint with auto-fix
npm run typecheck # Run TypeScript compiler without emitting filesnpm run prepare # Runs automatically on npm install, builds the projectThe library is structured around three main rendering strategies:
- Native Terminal Support: Uses
term-imgfor terminals with native image support (iTerm2, etc.) - Kitty Protocol: Direct image rendering for Kitty-compatible terminals (WezTerm, Konsole, etc.)
- ANSI Fallback: Block character rendering with RGB colors using chalk for universal compatibility
src/index.ts: Main API and rendering logic with intelligent terminal detectionsrc/gif-renderer.ts: FFmpeg-based GIF frame extraction and animation loopsrc/types.d.ts: TypeScript declarations for external modules
The rendering process follows this flow:
- Terminal Detection: Check environment variables and TTY status to determine capabilities
- Image Processing: Use Jimp for image manipulation (resizing, color extraction)
- Output Strategy: Select between native, Kitty protocol, or ANSI rendering
- Dimension Calculation: Handle percentage-based sizing and aspect ratio preservation
GIF rendering uses FFmpeg (via ffmpeg-static) to extract frames to temporary PNG files, then renders each frame in sequence with controlled timing. The animation loop supports:
- Frame rate limiting (maximumFrameRate option)
- Graceful cleanup of temporary files
- Playback control via returned stop function
The library exports a default object with four main methods:
buffer()/file(): Static image renderinggifBuffer()/gifFile(): Animated GIF rendering
All methods support consistent options for width, height, and aspect ratio preservation, with intelligent defaults based on terminal dimensions.
- chalk: Terminal color support
- ffmpeg-static: Bundled FFmpeg binary for GIF processing
- fluent-ffmpeg: FFmpeg wrapper API
- jimp: Image processing and manipulation
- log-update: Default frame renderer for animations
- term-img: Native terminal image support
- image-dimensions: Fast image dimension detection
- TypeScript: Primary language with ES2022 target
- ESLint: Code linting with TypeScript support
- Prettier: Code formatting
- TypeScript: Configured for Node16 module resolution with strict mode
- ESLint: Uses recommended TypeScript rules with custom unused variable handling
- Output: ES modules only, distributed via
dist/directory - Node Version: Requires Node.js >= 20
The examples/ directory contains usage demonstrations:
example.ts: Basic static image renderingexample_gif.ts: Animated GIF playbook with stop controlexample_pixel.ts: ANSI pixel rendering demo
Run examples with a TS runner like tsx or ts-node:
# After building the library (npm run build)
npx tsx examples/example.ts
npx tsx examples/example_gif.ts