Skip to content

Commit

Permalink
Merge pull request #1 from jacobwalker0814/bin
Browse files Browse the repository at this point in the history
Add basic executable
  • Loading branch information
lastguest committed Oct 16, 2014
2 parents 0af7f07 + 5d61546 commit 1fb8e3e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

<img src="http://drop.caffeina.co/image/1B133A0N3V0c/vocal.png" width="700" />
Expand Down
24 changes: 24 additions & 0 deletions bin/pixeler
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env php
<?php

// Include autoloader
require __DIR__.'/../../../autoload.php';

// Parse options from command line
$opts = array_merge([
'f' => 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;
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"minimum-stability": "dev",
"autoload": {
"psr-4": { "Pixeler\\" : "" }
}
},
"bin": ["bin/pixeler"]
}

0 comments on commit 1fb8e3e

Please sign in to comment.