// Date: 2015-02-17 // File and new size $filename = 'zaehler_bg.gif'; $len=1; if (isset($_GET["num"])) { $word=utf8_decode($_GET["num"]); $code=ord($word); $len=strlen($word); if ($word[$len-3] == '.') { $len--; } } // Content type header('Content-Type: image/png'); $width=$len*20+3; $height=37; // Load $thumb = imagecreate($width, $height); $source = imagecreatefromgif($filename); $black = imagecolorallocate($thumb, 0, 0, 0); $red = imagecolorallocate($thumb, 147, 15, 15); $grey = imagecolorallocate($thumb, 230, 230, 230); $white = ImageColorAllocate ($thumb, 200, 200, 200); // Resize $offset=0; for ($i=0; $i < strlen($word); $i++) { //echo "code: $code char: ".$word[$i]."\n
"; $row=0; $col=ord($word[$i])-48; if ($col>=0 && $col <=9) { imagecopyresized($thumb, $source, $i*21+5+$offset, 5, 0, $row*27, 20, 27, 20, 27); if ($len != strlen($word) && $i == strlen($word)-2) { // kommastelle nach oben verschoben $wert=ord($word[$i+1])-48; $y=27-$wert*24/10; ImageTTFText ($thumb, 18, 0, $i*21+6+$offset, $y, $white, "/usr/share/fonts/truetype/DejaVuSans-Bold.ttf", $word[$i]); } else if ($len != strlen($word) && $i == strlen($word)-1) { // kommastelle von unten kommend $y=54-(ord($word[$i])-48)*24/10; ImageTTFText ($thumb, 18, 0, ($i-1)*21+6+$offset, $y, $white, "/usr/share/fonts/truetype/DejaVuSans-Bold.ttf", ($word[$i-1]+1)<10?$word[$i-1]+1:0); } else { ImageTTFText ($thumb, 18, 0, $i*21+6+$offset, 27, $white, "/usr/share/fonts/truetype/DejaVuSans-Bold.ttf", $word[$i]); } } else { $offset=-13; } } imagesetthickness($thumb, 6); imagerectangle($thumb, $width-28, 0, $width-2, $height-2, $red); // red $dotx=$width-32; $doty=$height-9; imagefilledrectangle($thumb, $dotx, $doty, $dotx+3, $doty+3, $grey); // dot // Output imagepng($thumb); ?>