Skip to content

ericbreh/image_to_ascii

Repository files navigation

image_to_ascii

Convert images or camera output to ASCII art in real-time.

Camera Edit Edit

Usage

Real-time camera preview

import 'package:image_to_ascii/image_to_ascii.dart';

// Create camera controller
final controller = AsciiCameraController();
await controller.initialize();

// Display live ASCII using StreamBuilder
StreamBuilder(
  stream: controller.stream,
  builder: (context, snapshot) {
    if (snapshot.hasData) {
      return AsciiImageWidget(
        ascii: AsciiImage.fromSimpleString(snapshot.data!),
      );
    }
    return CircularProgressIndicator();
  },
)

// Control flash
await controller.flashOn();
await controller.flashOff();
await controller.flashAuto();

// Switch cameras
await controller.switchToFront();
await controller.switchToBack();

// Take a picture and convert to ASCII
final picture = await controller.takePicture();
// Then pass to convertImagePathToAscii()

// Dispose when done
await controller.dispose();

Convert image to ASCII

import 'package:image_to_ascii/image_to_ascii.dart';

// Convert image file to ASCII
final asciiImage = await convertImagePathToAscii('path/to/image.png');

// Or convert a ui.Image directly
final asciiImage = await convertImageToAscii(uiImage);

// Display
AsciiImageWidget(ascii: asciiImage)

Options

  • width / height - Set output dimensions (density)
  • dark / darkMode - Invert colors (white text on black)
  • color - Enable colored ASCII output
AsciiCameraController(
  darkMode: true,
  width: 150,
);

convertImagePathToAscii(
  'image.png',
  width: 100,
  dark: true,
  color: true,
);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors