Pixler: a transparent PNG pixel generator
I made a weensy little script for the theme I recently made (which I still have not named or prepared for distribution) which will generate single pixel transparent pngs to use as tiled background images in css.
demonstration toy
<?php $p = imagecreatetruecolor(1, 1); imagesavealpha($p, true); $o = (100 - (int) $_GET['o']) * 1.27; $c = imagecolorallocatealpha($p, (int) $_GET['r'], (int) $_GET['g'], (int) $_GET['b'], $o); imagefill($p, 0, 0, $c); header("Content-type: image/png"); imagepng($p); ?>
usage / parameters:
- r
- how much red to include: r=[0-255]
- g
- how much green to include: g=[0-255]
- b
- how much blue to include: b=[0-255]
- o
- how opaque the pixel should be: o=[0(fully transparent)-100(fully opaque)]
so…
- pixler.php?r=255&g=255&b=255&o=50
- will make a white pixel that is 50% visible.
- pixler.php?r=255&o=100
- will make a red pixel that is fully visible.
- pixler.php
- calling the script with no parameters will create an invisible black pixel (…).









May 13th, 2009 at 3:31 pm
awesome script! i’ve been looking for exactly this script!!!!! kudos!
May 13th, 2009 at 4:31 pm
@Jorge
this is one i made more recently, which is a tad better, and does gradients too:
http://github.com/re5et/trickyInc/blob/master/images/trickyImg.php
May 14th, 2009 at 8:50 pm
Pretty frikkin cool. Works like a charm.
Do you have examples for JPG and GIF too?
Thanks.
May 14th, 2009 at 9:43 pm
@DouG Molidor
i suspect that you are slightly confused. Neither JPG or GIF support alpha channel transparency.
June 23rd, 2009 at 12:00 pm
@atom i’ll try that out, thanks!
October 25th, 2009 at 2:26 am
Nice snippit! We are using it on our splash page for a new project coming up. Cheers!
November 28th, 2009 at 12:37 pm
博客写的很好,有很多值得学习的地方,给博主留个言,记得回访哦。
December 3rd, 2009 at 11:32 am
博主写的真的很好,在这里给你留个言了,我的网站比较前卫,博主不要介意啊,以后多多关照。
February 17th, 2010 at 5:59 am
Great code, thanks!
February 19th, 2010 at 9:22 am
青岛卓众(www.chinajoyzone.com)给博主拜年来了,新的一年,祝博主前途似锦。