PHP Classes

Pixeler: Render images as UTF-8 text characters

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 168 All time: 8,825 This week: 88Up
Version License PHP version Categories
pixeler 1.0.1MIT/X Consortium ...5.4PHP 5, Graphics, Text processing, Con...


This package can render images as UTF-8 text characters.

It can take a given image file and renders its pixels as a grid of text characters to be displayed in a text console eventually using ANSI color character controls.

The dither mode, the dither threshold values, and image scale are configurable parameters.

Picture of Stefano Azzolini
  Performance   Level  
Name: Stefano Azzolini <contact>
Classes: 3 packages by
Country: Italy Italy
Age: 42
All time rank: 3878158 in Italy Italy
Week rank: 410 Up18 in Italy Italy Up
Innovation award
Innovation award
Nominee: 2x




Render images in CLI with UTF-8 characters.

Scrutinizer Code Quality Total Downloads Latest Stable Version Latest Unstable Version License

<img src="" width="700" />


Require in your project with composer :

$ composer require lastguest/pixeler

This will also install a pixeler tool in :


It works exactly like the example below.


Create a file pixel.php :


// Include autoloader
include __DIR__."/vendor/autoload.php";

// Parse options from command line
$opts = array_merge([
    'd' => 1,    // Dithering mode : 0 = DITHER_NONE, 1 = DITHER_ERROR
    'f' => false,
    'r' => 1.0,  // Resize factor 1.0 = 100%
    'w' => 0.75, // Dither treshold weight
], getopt("f:r:w:d:ib"));

// An image file/url is required.
$opts['f'] || die("Must specify an image file.\n");

// The -i option inverts the image
$image = Pixeler\Pixeler::image($opts['f'], $opts['r'], isset($opts['i']), $opts['w'], $opts['d']);

// No colors if "-b" is passed
isset($opts['b']) && $image->clearColors();

// The Pixeler\Image instance render itself if casted to a string
echo $image;

$ php pixel.php -f -r .25 -w 0.25 -i

<img src="" width="700" />

$ php pixel.php -f -r 0.15 -w 0.5 -i

<img src="" width="700" />

$ php pixel.php -f -r 0.3 -w 0.5 -b

<img src="" width="700" />


Use the -d option to choose 1-bit dithering mode.

Command | Constant | Description ----|------|---- -d0 | Pixeler\Image::DITHER_NONE | Threshold 1-bit quantization -d1 | Pixeler\Image::DITHER_ERROR | Dither image with 1-bit Atkinson Dithering

Animation Example

You will see a lot of tearing, need some kind of vsync wait.


// Vendors
include __DIR__."/vendor/autoload.php";

$screen = new Pixeler\Canvas(160,100);
$sh2 = $screen->height()/2;
$sh4 = $sh2/1.5;
$ph = pi()/32;
$i = 0;

// To exit, press Ctr-C
  for ($x=0,$c=$screen->width(); $x < $c; $x++){
    $y = $sh4sin($i++/128 + $ph$x);
    $screen->setPixel($x,$sh2 + $y);
    $screen->setPixel($x,$sh2 + $y/2);
    $screen->setPixel($x,$sh2 + $y/4);
  echo $screen;

<img src="" width="700" />

  • Colors
  • Elephant
  • Video
  Files folder image Files  
File Role Description
Files folder imagebin (1 file)
Files folder imagesrc (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file Lic. License
Accessible without login Plain text file Doc. Auxiliary data

  Files folder image Files  /  bin  
File Role Description
  Accessible without login Plain text file pixeler Example Example CLI tool

  Files folder image Files  /  src  
File Role Description
Files folder imagePixeler (4 files)

  Files folder image Files  /  src  /  Pixeler  
File Role Description
  Plain text file Canvas.php Class Class source
  Plain text file Image.php Class Class source
  Plain text file Matrix.php Class Class source
  Plain text file Pixeler.php Class Main Class

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,825
This week:88Up
User Comments (1)
Nice class!!!
7 years ago (Miguel)