Skip to content

Latest commit

 

History

History
48 lines (31 loc) · 2.06 KB

File metadata and controls

48 lines (31 loc) · 2.06 KB

ASCII-ify

Convert images, videos, or webcam feeds into ASCII directly in your browser. Try it out here.

Original ASCII

Features

Key features include:

  • Support for image and video file uploads
  • Real-time webcam feed conversion
  • Customisable output dimensions, character sets, and colours
  • Copy ASCII to clipboard or download it as a PNG or MP4/WebM
  • Tweak image brightness and contrast
  • Zoom and pan controls

How It Works

ASCII Conversion

The core algorithm transforms visual media into ASCII through the following steps:

  1. Pixel Sampling: For each ASCII character position, a grid of pixels is sampled from the source image or video. Within each region, RGB values are averaged to determine overall brightness. A stride pattern optimises performance by sampling fewer pixels in larger regions.

  2. Luminance Calculation: The averaged RGB values are converted to a single luminance value using the ITU-R BT.709 coefficients, which reflect human perception of colour (green appears brighter than blue or red).

    $$L = (R \cdot 0.2126) + (G \cdot 0.7152) + (B \cdot 0.0722) \quad \text{where } R,G,B \in [0,1]$$
  3. Character Mapping: The luminance value (0-255) is mapped to an index in the character set. Higher luminance values correspond to denser characters (like @ or #), while lower values correspond to sparser characters (like spaces or dots).

Technologies

The application is built using React with Vite. State management is handled via React Context. Conversion logic is abstracted into custom hooks:

  • useUpload: Handles file and URL uploads and previews
  • useWebcam: Manages webcam streams and previews
  • useAscii: Implements the core ASCII conversion logic and output

Resources