diff --git a/README.md b/README.md index bbb4ffa..1e2b976 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ echo $image; ```bash -$ php -f http://drop.caffeina.co/image/160L0Y3C0a29/vocaloid.jpg -r .25 -w 0.25 -i +$ php pixel.php -f http://drop.caffeina.co/image/160L0Y3C0a29/vocaloid.jpg -r .25 -w 0.25 -i ``` diff --git a/bin/pixeler b/bin/pixeler new file mode 100755 index 0000000..9f6b1dc --- /dev/null +++ b/bin/pixeler @@ -0,0 +1,24 @@ +#!/usr/bin/env php + false, + 'r' => 1.0, // Resize factor 1.0 = 100% + 'w' => 0.75, // Dither treshold weight +], getopt("f:r:w: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']); + +// No colors if "-b" is passed +isset($opts['b']) && $image->clearColors(); + +// The Pixeler\Image instance render itself if casted to a string +echo $image; diff --git a/composer.json b/composer.json index 5988666..2233394 100644 --- a/composer.json +++ b/composer.json @@ -18,5 +18,6 @@ "minimum-stability": "dev", "autoload": { "psr-4": { "Pixeler\\" : "" } - } + }, + "bin": ["bin/pixeler"] }