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 (…).

trackback

Tags: , , , , 10 responses »
  1. Jorge's gravatar

    awesome script! i’ve been looking for exactly this script!!!!! kudos!

  2. atom's gravatar

    @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

  3. DouG Molidor's gravatar

    Pretty frikkin cool. Works like a charm.
    Do you have examples for JPG and GIF too?

    Thanks.

  4. atom's gravatar

    @DouG Molidor

    i suspect that you are slightly confused. Neither JPG or GIF support alpha channel transparency.

  5. Jorge's gravatar

    @atom i’ll try that out, thanks!

  6. The Sheraz's gravatar

    Nice snippit! We are using it on our splash page for a new project coming up. Cheers!

  7. 女性人体艺术's gravatar

    博客写的很好,有很多值得学习的地方,给博主留个言,记得回访哦。

  8. 人体艺术图片's gravatar

    博主写的真的很好,在这里给你留个言了,我的网站比较前卫,博主不要介意啊,以后多多关照。

  9. Guy's gravatar

    Great code, thanks!

  10. 青岛卓众信息科技有限公司's gravatar

    青岛卓众(www.chinajoyzone.com)给博主拜年来了,新的一年,祝博主前途似锦。

Leave a Reply

ok to use:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

bonus!

If you want to post code, you can use:

<pre lang="[language]">[code]</pre>

Where [language] is a valid geshi language type, and where [code] is your code.

I’ve made a new theme, help me name it.

I liked my old theme, but I was getting tired of it and wanted to try something new.  This theme is very different than my last (and I think pretty different in general), which is one of the things I was going for.

It has a full page flexible layout as opposed to a fixed width centered layout, is brightly colored rather than dark, and the biggest thing is that there is no JavaScript, and my last theme was filthy with the stuff.

There is some fine tuning to be done, once the little things are taken care of the theme will be available for download.

If anyone has a great name for it, please drop it in the comments.  Extra points if you can manage the word “thuggin” into it.  I can’t come up with a damn thing.

trackback

Tags: , , , 6 responses »
  1. nocash's gravatar

    Two for now:

    1) Thugginacious Chex
    2) Color Me Thuggin

  2. nocash's gravatar

    another:

    3) Thuggin Over the Rainbow

  3. Savageaphid's gravatar
    Savageaphid Says:

    1) Rainbow Sprite
    2) Strait Thuggin’ Stripes

  4. none's gravatar

    thuggery duggery

  5. Bob's gravatar

    Not to offend but how about “Ugly” as a theme name? Sorry, but I think the theme is too busy and hard to look at for long periods of time. It seems overly cluttered and there isn’t evne that much going on to make it feel that way other than the colors. I think the top part with the square boxes works for a header, but the strips should be either one solid color or maybe a gradient of two colors from top to bottom. Makes it easier to focus on what you are reading instead of getting a seizure from the hypnotic lines. The transparent box over the colored area make it hard to read the text and it just looks sort of web 1.0, or back in the day someones first ever home page designs on something like angelfire or geocities. You are using wordpress, one of the greatest blogging tools on the net, and there are literally thousands of themes to choose from. You don’t have to use on of theirs, but maybe get some ideas on where to start with simple, easy to read blogs.

    Hope you take this as constructive criticism, as no one seemed to be addressing this issue.

  6. atom's gravatar

    @Bob,

    I never take anything as constructive criticism, your remarks have damaged me deeply.

    P.S: Thank you for the tips about the gradients, and WordPress having themes available!

Leave a Reply

ok to use:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

bonus!

If you want to post code, you can use:

<pre lang="[language]">[code]</pre>

Where [language] is a valid geshi language type, and where [code] is your code.