2012-12-20 2 views
-2

Je crée une image dynamiquement en utilisant PHP GD. donc quand j'exécute index.php il créer image.png mais je veux l'image dans index.php par exemple, je peux utiliser <img src="index.php">créer une image dynamiquement - PHP GD

+0

http://stackoverflow.com/questions/2010742/image-processing-et-output-using-gd-in-php – ke20

Répondre

4

Vous devez définir le type de contenu en-tête à header('content-type: image/jpeg');
J'ai mis en place un code similaire une fois pour un captcha

header("Content-type: image/png"); 
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past 
$string = "Type Me"; 
$im  = imagecreatefrompng(IMAGEDIR."captcha.png"); 
$orange = imagecolorallocate($im, 0, 0, 0); 
$px  = (imagesx($im) - 7.5 * strlen($string))/2; 
imagestring($im, 5, $px, 9, $string, $orange); 
imagepng($im); 
imagedestroy($im);