1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| <?php
header("Content-type: image/png");
function createLettre($lettre)
{
$image = imagecreatetruecolor(20, 20);
$bgcolor = imagecolorallocate($image, 200, 200, 255);
$color = imagecolorallocate($image, rand(0, 200), rand(0, 200), rand(0, 200));
imagefill($image, 0, 0, $bgcolor);
$font = rand(1, 5);
imagestring($image, $font, rand(0, 20 - imagefontwidth($font)), rand(0, 20 - imagefontheight($font)), $lettre, $color);
//imagerotate($image, rand(-10, 10), $bgcolor); //à décommenter si t'as imagerotate...
return $image;
}
$texte = "jDh6E4mP"; // à générer aléatoirement...
$image = imagecreatetruecolor(160, 20);
$black = imagecolorallocate($image, 0, 0, 0);
for ($i=0; $i<8; $i++)
{
$lettre = createLettre($texte[$i]);
imagecopy($image, $lettre, $i*20, 0, 0, 0, 20, 20);
imagedestroy($lettre);
}
imagepng($image);
imagedestroy($image);
?> |
Partager