Pluto UIpluto/ui
Components

ASCII Image

Convert images to ASCII art with advanced options including edge detection, dithering algorithms, and customizable charsets.

Loading...
// Code for ascii-image/basic

Installation

Loading installation instructions...

Usage

import { AsciiImage } from "@/components/pluto-ui/ascii-image"
<AsciiImage src="https://example.com/image.jpg" width={80} fontSize={6} />

Props

PropTypeDefaultDescription
srcstring-Image source URL
widthnumber100ASCII art width in characters
brightnessnumber0Brightness adjustment (-255 to 255)
contrastnumber0Contrast adjustment (-255 to 255)
blurnumber0Blur amount in pixels
ditheringbooleantrueEnable dithering
ditherAlgorithmDitherAlgorithm"floyd"Dithering algorithm: "floyd", "atkinson", "noise", or "ordered"
invertbooleanfalseInvert colors
ignoreWhitebooleantrueIgnore white pixels
charsetCharset"detailed"Character set: "standard", "blocks", "binary", "hex", "detailed", or "manual"
manualCharstring"0"Custom character for manual charset
edgeMethodEdgeMethod"none"Edge detection method: "none", "sobel", or "dog"
edgeThresholdnumber100Threshold for Sobel edge detection (0-255)
dogEdgeThresholdnumber100Threshold for Difference of Gaussians edge detection
fontSizenumber7Font size in pixels
classNamestring-Additional CSS classes
onAsciiGenerated(ascii: string) => void-Callback when ASCII art is generated

Examples

Basic Usage

Loading...
// Code for ascii-image/basic

Edge Detection

// Code for ascii-image/edge-detection

The component supports two edge detection methods:

  • Sobel: Classic edge detection using gradient magnitude
  • Difference of Gaussians (DoG): Advanced edge detection using multi-scale filtering

Dithering Algorithms

// Code for ascii-image/dithering

Four dithering algorithms are available:

  • Floyd-Steinberg: Most common, produces good quality
  • Atkinson: Softer, more diffused error
  • Ordered: Uses Bayer matrix for structured dithering
  • Noise: Random dithering for artistic effects

Character Sets

// Code for ascii-image/charsets

Multiple character sets are available:

  • detailed: Full range of characters (default)
  • standard: Basic ASCII characters
  • blocks: Unicode block characters
  • binary: Just 0s and 1s
  • hex: Hexadecimal characters
  • manual: Custom character

Features

  • ✓ Multiple edge detection methods (none, Sobel, DoG)
  • ✓ Four dithering algorithms (Floyd-Steinberg, Atkinson, Ordered, Noise)
  • ✓ Adjustable brightness, contrast, and blur
  • ✓ Multiple character sets including custom
  • ✓ Invert colors and ignore white options
  • ✓ Theme-aware styling
  • ✓ Callback for generated ASCII art

Notes

  • The component uses HTML5 Canvas for image processing
  • Images are processed client-side in the browser
  • For best results, use images with good contrast
  • CORS-enabled images are required for cross-origin sources

Credits

This component was inspired by Mikhail-Bespalov (https://codepen.io/Mikhail-Bespalov/full/JoPqYrz) demonstrations.