Code Dump: Icongen

Here’s a quick and dirty php script (using GD) that creates icons for my android phone. I got fed up at SimpleText, which no longer creates transparent images, and appears to have been abandoned by its developer. Images are created from the URL


into a folder called images.

<!--?php &lt;br ?--> $img_width=128;
$handle = ImageCreatetruecolor ($img_width,$img_height) or die ("Cannot Create image");
$bg_color = ImageColorAllocate ($handle, 0,0,0);
$black = ImageColorAllocate ($handle, 0,0,0);
$white = ImageColorAllocate ($handle, 255,255,255);
$red = ImageColorAllocate ($handle, 255,0,0);
$blue = ImageColorAllocate ($handle, 50,50,150);
$txt_color = $black;
$font_size = 26;
$txt_max_width = intval(0.8 * $img_width);
if($_GET['name']) { $text=$_GET['name'];
} else { $text='snap';
} #do { #$font_size++;
$p = imagettfbbox($font_size,0,$font_path,$text);
#} while ($txt_width &lt;= $txt_max_width); $y = $img_height * 0.57; // baseline of text at 90% of $img_height $x = ($img_width - $txt_width) / 2; imagettftext($handle, $font_size, 0,$x, $y, $white, $font_path, $text); ImagePng ($handle,'images/'.$text.'.png'); imagedestroy($handle); ?&gt;<img src="images/&lt;?php" />.png&gt;

OSHA Label Generator

[OSHA Label Generator]( “OSHA Label Generator”)
This is something I whipped up yesterday afternoon/this morning after an employee requested I help him create a template for OSHA labels, as apparently OSHA standards have changed or something. As he described what he wanted, I knew that it would be painful to create in Word, and it’d be awful to use and attempt to get everything in place, aligned, and to add the necessary icons. My way isn’t the simpler way, but it a better way.