2017 © Pedro Peláez
 

library pixeler

CLI Image renderer

image

lastguest/pixeler

CLI Image renderer

  • Monday, May 8, 2017
  • by lastguest
  • Repository
  • 15 Watchers
  • 429 Stars
  • 677 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 16 Forks
  • 1 Open issues
  • 5 Versions
  • 4 % Grown

The README.md

Pixeler

Gitter, (*1)

Render images in CLI with UTF-8 characters., (*2)

Scrutinizer Code Quality Total Downloads Latest Stable Version Latest Unstable Version License, (*3)

, (*4)

Installation

Require in your project with composer :, (*5)

$ composer require lastguest/pixeler

This will also install a pixeler tool in :, (*6)

your_project_dir/vendor/bin/pixeler

It works exactly like the example below., (*7)

Example

Create a file pixel.php :, (*8)

<?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 http://drop.caffeina.co/image/160L0Y3C0a29/vocaloid.jpg -r .25 -w 0.25 -i

, (*9)

$ php pixel.php -f http://flippywall.com/wp-content/uploads/2014/07/Manga-Girl-Wallpaper-16.jpg -r 0.15 -w 0.5 -i

, (*10)

$ php pixel.php -f http://blog.circleci.com/wp-content/uploads/2014/07/elephant.jpg -r 0.3 -w 0.5 -b

, (*11)

Dithering

Use the -d option to choose 1-bit dithering mode., (*12)

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., (*13)

<?php

// 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
while(1){
  $screen->clear();
  for ($x=0,$c=$screen->width(); $x < $c; $x++){
    $y = $sh4*sin($i++/128 + $ph*$x);
    $screen->setPixel($x,$sh2 + $y);
    $screen->setPixel($x,$sh2 + $y/2);
    $screen->setPixel($x,$sh2 + $y/4);
    $screen->setPixel($x,$sh2);
  }
  echo $screen;
}

, (*14)

The Versions

08/05 2017

dev-master

9999999-dev https://github.com/lastguest/pixeler

CLI Image renderer

  Sources   Download

MIT

The Requires

  • php >=5.4

 

cli image graphics render pixel utf8

02/04 2017

1.1.2

1.1.2.0 https://github.com/lastguest/pixeler

CLI Image renderer

  Sources   Download

MIT

The Requires

  • php >=5.4

 

cli image graphics render pixel utf8

31/03 2016

1.1.0

1.1.0.0 https://github.com/lastguest/pixeler

CLI Image renderer

  Sources   Download

MIT

The Requires

  • php >=5.4

 

cli image graphics render pixel utf8

17/10 2014

1.0.1

1.0.1.0 https://github.com/lastguest/pixeler

CLI Image renderer

  Sources   Download

MIT

The Requires

  • php >=5.4

 

cli image graphics render pixel utf8

16/10 2014

1.0.0

1.0.0.0 https://github.com/lastguest/pixeler

CLI Image renderer

  Sources   Download

MIT

The Requires

  • php >=5.4

 

cli image graphics render pixel utf8