Bonjour
Voici mon script qui marche SAUF pour les images gifs avec fond transparent !
Je n'arrive pas à m'en sortir, pourriez vous m'aider ? Et par la meme occasion améliorer mon code pour que je vois mes erreurs ? Merci infiniement

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<html>
<head>
<body>
<?php
 
function LoadJPEG ($imgURL) {
 
   ##-- Get Image file from Port 80 --##
   $fp = fopen($imgURL, "r");
   $imageFile = fread ($fp, 3000000);
   fclose($fp);
 
   ##-- Create a temporary file on disk --##
   $tmpfname = tempnam ("/temp", "IMG");
 
   ##-- Put image data into the temp file --##
   $fp = fopen($tmpfname, "w");
   fwrite($fp, $imageFile);
   fclose($fp);
 
   ##-- Load Image from Disk with GD library --##
   $imurl = imagecreatefromjpeg ($tmpfname);
 
   ##-- Delete Temporary File --##
   unlink($tmpfname);
 
   ##-- Check for errors --##
   if (!$imurl) {
       print "Could not create JPEG image $imgURL";
   }
 
   return $imurl;
}
 
$urlphoto = $_POST['urlphoto'];
$titre = $_POST['titre'];
$de =  $_POST['de'];
$lignes =  $_POST['lignes'];
$font =  $_POST['liste'];
$hauteurli =  $_POST['hauteurli'];
 
$largeur = 567; 
$hauteur = 794; 
 
// on crée une ressource pour notre image qui aura comme largeur $largeur et $hauteur comme hauteur (on place également un or die si la création se passait mal afin d'avoir un petit message d'alerte)
$im = @ImageCreate ($largeur, $hauteur) or die ("Erreur lors de la création de l'image");
 
// on place tout d'abord la couleur blanche dans notre table des couleurs (je vous rappelle donc que le blanc sera notre couleur de fond pour cette image).
$blanc = ImageColorAllocate ($im, 255, 255, 255);  
 
// on place aussi le noir dans notre palette, ainsi qu'un bleu foncé et un bleu clair
$noir = ImageColorAllocate ($im, 0, 0, 0);  
$bleu_fonce = ImageColorAllocate ($im, 75, 130, 195);
$bleu_clair = ImageColorAllocate ($im, 95, 160, 240);
 
// Le texte à dessiner
$text = strtr($titre, "ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ", "AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy");
$text6 = strtr($de, "ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ", "AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy");
 
$textepos = $hauteur-100;
$textepos2 = $hauteur-50;
// Ajout du texte
imagettftext($im, 20, 0, 10, $textepos, $noir, $font, $text);
imagettftext($im, 20, 0, 10, $textepos2, $noir, $font, $text6);
 
// File and new size
$filename = $urlphoto;
 
 
// Get new sizes
list($width, $height) = getimagesize($filename);
 
if ($width < 250 || $height < 250)
{
$thumbsize=$width;
}
else
{
$thumbsize=$largeur-10;
}
 
 
	$imgratio=$width/$height;
 
	if ($imgratio>1)
	{
    		 $newwidth = $thumbsize;
    		 $newheight = $thumbsize/$imgratio;
	}
   			else
	{
     $newheight = $thumbsize;
     $newwidth = $thumbsize*$imgratio;
	}
 
 
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
 
//trouver le type de fichier
 
if(substr($urlphoto,-3) == "jpeg" || (substr($urlphoto,-3)) == "jpg" )
{
     $source = imagecreatefromjpeg($urlphoto);
}
 
if(substr($urlphoto,-3) == "gif" )
{
$source = imagecreatefromgif($urlphoto);
 
}
 
 
 
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
 
 
// Les fonctions imagesx et imagesy renvoient la largeur et la hauteur d'une image 
$largeur_source = imagesx($thumb); 
$hauteur_source = imagesy($thumb); 
//$largeur_destination = imagesx($destination); 
//$hauteur_destination = imagesy($destination); 
$largeur_destination = imagesx($im); 
$hauteur_destination = imagesy($im); 
 
// On veut placer le logo en bas à droite, on calcule les coordonnées où on doit placer le logo sur la photo 
/*$destination_x = $largeur_destination - $largeur_source; 
$destination_y =  $hauteur_destination - $hauteur_source; */
$destination_x = $largeur_destination - $largeur_source-350; 
$destination_y =  $hauteur_destination - $hauteur_source-530; 
 
// On met le logo (source) dans l'image de destination (la photo) 
imagecopymerge($im, $thumb, 10, 10, 0, 0, $largeur_source, $hauteur_source, 100);
 
if(substr($urlphoto,-3) == "jpeg" || (substr($urlphoto,-3)) == "jpg" )
{
imagejpeg ($im,"papiers_lettres/papier_lettre.jpg",100);
echo "<img border=\"1\" src=\"papiers_lettres/papier_lettre.jpg\">";
}
 
if(substr($urlphoto,-3) == "gif" )
{
imagegif ($im,"papiers_lettres/papier_lettre.gif",100);
echo "<img border=\"1\" src=\"papiers_lettres/papier_lettre.gif\">";
}
 
 
 
?> 
 
 
</body>
</html>