<?php
//include_once('xxxxxx.php');
// Si utilisé l'mage ne se génére plus.... ????
// Je voudrai importer une var texte $toto du fichier xxxx.php pour la passer
// à la fonction create_image() et ainsi l'afficher sur l'image générée.
create_image();
exit();
function create_image() {
//Let's generate a totally random string using md5
$md5 = md5(rand(0,999));
//We don't need a 32 character long string so we trim it down to 10
$pass = substr($md5, 0, 10);
//Set the image width and height
$width = 500;
$height = 40;
//Create the image resource
$image = ImageCreate($width, $height);
$string = "MyString";
//We are making three colors, white, black and gray
$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$grey = ImageColorAllocate($image, 204, 204, 204);
$green = ImageColorAllocate($image, 0, 192, 0);
//Make the background black
// ImageFill($image, 0, 0, $grey);
$image = imagecreatefromjpeg("myjpg_pict.jpg");
//Add randomly generated string in white to the image
ImageString($image, 3, 30, 3, $pass, $white);
imagestring ( $image , 5, 20 , 20 , $string , $green );
//Throw in some lines to make it a little bit harder for any bots to break
ImageRectangle($image,0,0,$width-1,$height-1,$grey);
imageline($image, 0, $height/2, $width, $height/2, $grey);
imageline($image, $width/2, 0, $width/2, $height, $grey);
header("Content-Type: image/jpeg");
//Output the newly created image in jpeg format
ImageJpeg($image); // ImageJpeg($image'./myimage.jpg');
//Free up resources
ImageDestroy($image);
}
?>
Partager