Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > Images > GD
GD Forum d'entraide pour l'extension GD permettant de manipuler des images en PHP. Avant de poster -> tutoriels GD
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 04/07/2007, 12h32   #1
Débutant
 
Inscription : mai 2005
Messages : 1 959
Détails du profil
Informations personnelles :
Localisation : Suisse

Informations forums :
Inscription : mai 2005
Messages : 1 959
Points : 615
Points : 615
Par défaut Problème pour charger GD

Bonjour,
j'utilise un code qui demande cette fonction
Code :
imagecreatetruecolor($width,$height);
je recois ce message d'erreur
Citation:
Fatal error: Call to undefined function: imagecreatetruecolor() in d:\easyphp1-8\www\new\include\en\contact\anti_spam.php on line 16
J'ai lu la doc concernat cette fonction
http://ch2.php.net/imagecreatetruecolor
et si j'ai bien compris cette ligne
Citation:
Depending on your PHP and GD versions this function is defined or not. With PHP 4.0.6 through 4.1.x this function always exists if the GD module is loaded, but calling it without GD2 being installed PHP will issue a fatal error and exit. With PHP 4.2.x this behaviour is different in issuing a warning instead of an error. Other versions only define this function, if the correct GD version is installed.
Comment puis-je etre sure que GD est bien chargé. J'ai fait un phpinfo() et GD est activé

Si non que pourriez vous me dire sur ce message d'erreur?

Pour info voici tout le code
Code :
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 
<?php 
session_start();
// type de flood
#$name = $_GET['name'];
$name = 'na';
// nb de caractères
#$strlen = (int) $_GET['strlen'];
$strlen= '4';
 
// taille de l'image ( width )
$width = $strlen * 30 + 20;
$height = 60;
 
// création
$img = imagecreatetruecolor($width,$height);
// antialising, c'est plus bô! :-)
imageantialias( $img, 1 );
 
// chaine
$string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$chaine = '';
for( $i = 0; $i < $strlen; $i++ )
$chaine .= $string[ mt_rand( 0, 35 ) ];
 
$_SESSION[ $name ] = $chaine;
 
// couleur de départ
$c1 = array( mt_rand( 200, 255), mt_rand( 200, 255), mt_rand( 200, 255) );
// couleur finale
$c2 = array( mt_rand( 150, 200), mt_rand( 150, 200), mt_rand( 150, 200) );
 
$colors = array( imagecolorallocate( $img, 70, 130, 255 ) , 
										 imagecolorallocate( $img, 255, 237, 175 ), 
											 imagecolorallocate( $img, 166, 250, 186 ), 
											 imagecolorallocate( $img, 253, 188, 251 ), 
											 imagecolorallocate( $img, 255, 255, 255 ) );
 
// création de l'image
for( $i = 0; $i < $width; $i++ )
{
$r = $c1[0] + $i * ( $c2[0] - $c1[0] ) / $width;
$v = $c1[1] + $i * ( $c2[1] - $c1[1] ) / $width;
$b = $c1[2] + $i * ( $c2[2] - $c1[2] ) / $width;
$color = imagecolorallocate( $img, $r, $v, $b );
 
imageline( $img, $i, 0, $i, $height, $color );
}
 
// caractères
for( $i = 0; $i < $strlen; $i++ )
{
$col = imagecolorallocate( $img, mt_rand( 0, 120 ),mt_rand( 0, 120 ), mt_rand( 0, 120 ));
 
imagettftext( $img, mt_rand( 20, 25 ), 
mt_rand( -30, 30 ), 
													   10 + $i * 30, 35, 
													   $col, 
													   'comic.ttf', 
													   $chaine[ $i ] );
}
 
// quelques lignes qui embêtent
for( $i = 0; $i < 8; $i++ )
{
imageline( $img, mt_rand(0, $width), 
mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $colors[mt_rand( 0, 4 )] );
}
 
$noir = imagecolorallocate( $img, 0, 0, 0 );
 
// bordure
imageline( $img, 0, 0, $width, 0, $noir );
imageline( $img, 0, 0, 0, $height, $noir );
imageline( $img, $width - 1, 0, $width - 1, $height, $noir );
 
// header: image
header("Content-type: image/png");
imagepng( $img ); 
imagedestroy( $img );
?>
Merci
__________________
Il ne suffit pas de tout savoir. Vouloir et persévérer, c'est déjà presque tout!
pierrot10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/07/2007, 19h01   #2
Rédacteur/Modérateur
 
Avatar de Deepin
 
Homme Deepin
Ingénieur - Chef de projet Modélisation/Simulation
Inscription : avril 2004
Messages : 1 341
Détails du profil
Informations personnelles :
Nom : Homme Deepin
Localisation : Ile Maurice

Informations professionnelles :
Activité : Ingénieur - Chef de projet Modélisation/Simulation
Secteur : Industrie

Informations forums :
Inscription : avril 2004
Messages : 1 341
Points : 7 085
Points : 7 085
Envoyer un message via Skype™ à Deepin
hello,
As tu verifié le fichier de conf php.ini aussi??
A++ et bon courage.
Deepin est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/07/2007, 17h08   #3
Membre régulier
 
Avatar de knoodrake
 
Inscription : juin 2007
Messages : 86
Détails du profil
Informations personnelles :
Âge : 26
Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

Informations forums :
Inscription : juin 2007
Messages : 86
Points : 74
Points : 74
regarde le texte en francais:
Citation:
Suivant votre version de PHP et de GD, cette fonction est définie ou non. De PHP version 4.0.6 à la version 4.1.x, cette fonction existe toujours si le module GD est chargé, mais l'appeler sans avoir GD2 d'installé fera que PHP lancera une erreur fatale et sortira. Avec PHP 4.2.x, ce comportement est différent et PHP lancera une alerte au lieu d'une erreur. Pour les autres versions de PHP, cette fonction n'est définie que si une version correcte de GD est installée.
  • Tu doit avoir GD2 d'installé pour l'utiliser.
  • note: le php.ini ne te donnera aucune info supplémentaire par rapport a php_info()
  • pour savoir si elle existe: if(function_exists('imagecreatetruecolor')) { /* ... */ } else trigger_error('bonne version de GD introuvable',E_USER_ERROR);
knoodrake est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 08h00.


 
 
 
 
Partenaires

Hébergement Web