Skip to content

Instantly share code, notes, and snippets.

@aaronpk
Created October 16, 2013 21:13
Show Gist options
  • Select an option

  • Save aaronpk/7014990 to your computer and use it in GitHub Desktop.

Select an option

Save aaronpk/7014990 to your computer and use it in GitHub Desktop.
RewriteEngine on
RewriteRule ([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})\.png img.php?r=$1&g=$2&b=$3 [QSA,L]
<?php
$r = $_GET['r'];
$g = $_GET['g'];
$b = $_GET['b'];
$im = imagecreatetruecolor(64,64);
$color = imagecolorallocate($im, hexdec($r), hexdec($g), hexdec($b));
imagefill($im, 0,0, $color);
header('Content-type: image/png');
imagepng($im);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment