Helical Alpha Code

pngpix: dynamic pixel generation

pngpix was inspired by the venerable pixelgif.com. However, not all of us like GIFs.

Anyway, this has much the same interface as pixelgif.com, with a custom transparency option (and optional .png extension), suited to the more-featureful image format. If brief, you feed pngpix.php a query string in the format "colour[/transparency][.png]" via whatever .htaccess voodoo you prefer. I like requiring the .png extension since it gives me control over external use of the script with my hotlinking protection ("Hotlink Hades" will be released when it's complete: guaranteed to make bandwidth thieves wish they hadn't stolen from you, after giving them enough pageloads with the stolen goods to feel suitably smug and secure. *grin*).

A couple of caveats: this is sock-drawer software (meaning the interface is designed around "pragmatically turning my whims into principles," in much the same way as my sock drawer is organized). Anything but a six-character colour code will be dropped in favour of a random colour, and all colours and transparencies are used modulo their maximum values.

Oh, and this does cache generated png files (for a dubious speed increase), so you'll want it's cache directory outside your document root (since it has to be 777'd). However, it doesn't clean up its cache, so if you serve it publically, you'll probably want to clean the cache on a cronjob or something. Or just put it in /tmp . . . As yet, it doesn't handle caching errors, so if there are writability problems, they'll be caught by PHP in a potentially-ugly script breakage. This is on the slate for v0.2a.

Note: Once you've finished testing your install (especially any .htaccess black magic), you may want to comment out the "X-query-string" header line. It's there only so you can see what the script is seeing while you get it up and running.

pngpix | Download Source | View Source