bonjour,
Je cherche à créer une image à l'aide d'une fonction.
J'ai créé un fichier g1.php qui contient:
et j'appelle la fonction dans un fichier HTML t1.php:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <?php header("Content-type: image/png"); function Dessin($w=100, $h=50) { $im=imagecreate($w,$h); $blanc=imagecolorallocate($im,0xff,0xff,0xff); $noir=imagecolorallocate($im,0,0,0); $string="$w x $h"; imagestring($im,1,10,10,$string,$noir); $ret=imagepng($im); // imagedestroy($im); return $ret; }; ?>
mais l'image ne s'affiche pas,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <? session_start(); include "g1.php"; ?> <html> <head></head> <body> <h3>essai graphique</h3> <img src="<? echo Dessin(400,200); ?>"><br> </body> </html>
Firefox m'affiche
Qu'ai-je fait de mal?L'image “http://127.0.0.1/Cyril/php/t1.php” ne peut être affichée car elle contient des erreurs.
Partager