All Projects → lastguest → Pixeler

lastguest / Pixeler

Licence: mit
CLI image renderer

Projects that are alternatives of or similar to Pixeler

Image To Xls
A simple tool to make ascii art from an image using excel colored cells.
Stars: ✭ 75 (-83.87%)
Mutual labels:  cli, pixel-art
Github Spray
Draw on your GitHub contribution graph ░▒▓█
Stars: ✭ 908 (+95.27%)
Mutual labels:  cli, pixel-art
Dshb
macOS system monitor
Stars: ✭ 446 (-4.09%)
Mutual labels:  cli
Macaca Cli
Macaca command-line interface
Stars: ✭ 458 (-1.51%)
Mutual labels:  cli
Drive Cli
A command line interface for accessing google drive
Stars: ✭ 449 (-3.44%)
Mutual labels:  cli
Bubbletea
A powerful little TUI framework 🏗
Stars: ✭ 7,886 (+1595.91%)
Mutual labels:  cli
2048.c
Console version of the game "2048" for GNU/Linux
Stars: ✭ 453 (-2.58%)
Mutual labels:  cli
Spotify Cli Linux
🎶 A command line interface to Spotify on Linux
Stars: ✭ 443 (-4.73%)
Mutual labels:  cli
Docker Debug
use new container attach on already container go on debug
Stars: ✭ 463 (-0.43%)
Mutual labels:  cli
Prettier Eslint Cli
CLI for prettier-eslint
Stars: ✭ 451 (-3.01%)
Mutual labels:  cli
Xcodegen
A Swift command line tool for generating your Xcode project
Stars: ✭ 5,032 (+982.15%)
Mutual labels:  cli
Gem Release
Release your ruby gems with ease.
Stars: ✭ 448 (-3.66%)
Mutual labels:  cli
Cobra
A Commander for modern Go CLI interactions
Stars: ✭ 24,437 (+5155.27%)
Mutual labels:  cli
Exiv2
Image metadata library and tools
Stars: ✭ 454 (-2.37%)
Mutual labels:  cli
Hn Cli
📰 CLI to browse Hacker News
Stars: ✭ 448 (-3.66%)
Mutual labels:  cli
Pxltrm
🖌️ pxltrm - [WIP] A pixel art editor inside the terminal
Stars: ✭ 459 (-1.29%)
Mutual labels:  pixel-art
Pulsemixer
CLI and curses mixer for PulseAudio
Stars: ✭ 441 (-5.16%)
Mutual labels:  cli
Macos Wallpaper
Manage the desktop wallpaper on macOS
Stars: ✭ 450 (-3.23%)
Mutual labels:  cli
Curriculum
Dive into our 7-month web development program covering HTML, CSS, Javascript, Node, and React!
Stars: ✭ 453 (-2.58%)
Mutual labels:  cli
Es2csv
Export from an Elasticsearch into a CSV file
Stars: ✭ 465 (+0%)
Mutual labels:  cli

Pixeler

Gitter

Render images in CLI with UTF-8 characters.

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

Installation

Require in your project with composer :

$ composer require lastguest/pixeler

This will also install a pixeler tool in :

your_project_dir/vendor/bin/pixeler

It works exactly like the example below.

Example

Create a file pixel.php :

<?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
$ php pixel.php -f http://flippywall.com/wp-content/uploads/2014/07/Manga-Girl-Wallpaper-16.jpg -r 0.15 -w 0.5 -i
$ php pixel.php -f http://blog.circleci.com/wp-content/uploads/2014/07/elephant.jpg -r 0.3 -w 0.5 -b

Dithering

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.

<?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;
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].