This commit is contained in:
Josh Sherman 2016-02-20 11:17:29 -05:00
parent 971b579ccc
commit 76c3340df6
3 changed files with 69 additions and 0 deletions

28
README.md Normal file
View file

@ -0,0 +1,28 @@
# php-pixel
> Yo Dawg, I herd you like pixels, so I put a pixel in your pixel so you can
> pixel while you pixel.
Why does this exist? Because I got sick of looking up how to generate a single
transparent pixel in PHP.
## Installation
```
composer require "joshtronic/php-pixel:dev-master"
```
## Usage
### GIF
```
joshtronic\Pixel::gif();
```
### PNG
```
joshtronic\Pixel::png();
```

23
composer.json Normal file
View file

@ -0,0 +1,23 @@
{
"name": "joshtronic/php-pixel",
"description": "Generate a 1x1 transparent pixel",
"version": "1.0.0",
"type": "utility",
"keywords": ["image", "pixel", "transparent", "gif", "png", "beacon", "tracking"],
"homepage": "https://github.com/joshtronic/php-pixel",
"license": "MIT",
"authors": [{
"name": "Josh Sherman",
"email": "hello@joshtronic.com",
"homepage": "http://joshtronic.com"
}],
"require-dev": {
"php": ">=4.0.0"
},
"require-dev": {
"satooshi/php-coveralls": "dev-master"
},
"autoload": {
"psr-4": {"joshtronic\\": "src/"}
}
}

18
src/Pixel.php Normal file
View file

@ -0,0 +1,18 @@
<?php
namespace joshtronic;
class Pixel
{
public static function gif()
{
header('Content-Type: image/gif');
echo base64_decode('R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==');
}
public static function png()
{
header('Content-Type: image/png');
echo base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=');
}
}