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 24/01/2008, 14h12   #1
Invité de passage
 
Inscription : décembre 2007
Messages : 26
Détails du profil
Informations personnelles :
Âge : 39
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : décembre 2007
Messages : 26
Points : 1
Points : 1
Par défaut Créer une image à partir d'un fichier

Bonjour,

J'aimerais utiliser GD pour générer une image à partir d'un fichier contenant ceci, sachant que chaque image fait 32x32.
Je ne connaît pas grand chose à GD et malgré la lecture du tutoriel je suis un peu perdu.

Voici le fichier type (chaque ligne représente un Y, chaque colonne un X, ici le fichier va de X=0 à X=14, idem pour Y):
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
45.jpg,53.jpg,53.jpg,53.jpg,53.jpg,53.jpg,53.jpg,53.jpg,53.jpg,53.jpg,53.jpg,53.jpg,53.jpg,53.jpg,46.jpg
50.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,51.jpg
50.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,143.jpg
50.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg
50.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,128.jpg,137.jpg,129.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg
48.jpg,142.jpg,2.jpg,2.jpg,2.jpg,2.jpg,140.jpg,49.jpg,139.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg
49.jpg,50.jpg,2.jpg,2.jpg,2.jpg,2.jpg,130.jpg,138.jpg,131.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,63.jpg
49.jpg,50.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg
49.jpg,48.jpg,142.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg
49.jpg,49.jpg,50.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg
49.jpg,49.jpg,50.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,141.jpg,52.jpg,52.jpg,52.jpg,142.jpg,2.jpg
49.jpg,49.jpg,50.jpg,2.jpg,2.jpg,2.jpg,2.jpg,2.jpg,141.jpg,47.jpg,49.jpg,49.jpg,49.jpg,50.jpg,2.jpg
49.jpg,49.jpg,48.jpg,52.jpg,52.jpg,52.jpg,52.jpg,52.jpg,47.jpg,49.jpg,49.jpg,45.jpg,53.jpg,144.jpg,2.jpg
49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,48.jpg,142.jpg,2.jpg,2.jpg
49.jpg,207.jpg,49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,49.jpg,48.jpg,52.jpg,52.jpg
Pourriez vous m'indiquer comment procéder ?
MarcCC est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/01/2008, 23h03   #2
Invité de passage
 
Inscription : décembre 2007
Messages : 26
Détails du profil
Informations personnelles :
Âge : 39
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : décembre 2007
Messages : 26
Points : 1
Points : 1
Bon, j'ai essayé comme ceci :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
 $image_carte = @imagecreatetruecolor (480,480) or die ("Impossible de crée un flux d'image GD");
 
        //Je lit le fichier de map
 
        $fp = fopen("maps/".$_POST['carte_edit'].".txt","r");
        $dst_y=0;
        while(!feof($fp))
        {
             $buffer = fgets($fp, 4096);
             $images=explode(",",$buffer);
             $nbre=count($images);
             for($i=0;$i<$nbre;$i++)
             {
                $dst_x=$i*32;
                $source=$rep.$images[$i];
                imagecopy($image_carte ,$source,$dst_x,$dst_y,0,0,32,32); 
               }
             $dst_y=$dst_y+32;
        }
        imagecolortransparent($image_carte);
        imagepng($image_carte, "maps/".$_POST['carte_edit'].".png");
        imageDestroy ($image_carte);
Mais celà me sort l'erreur suivante :
Citation:
Warning: imagecopy(): supplied argument is not a valid Image resource in /home/lesmonde/public_html/admin/gen_map.php on line 74
Resource id #4 ,images/ville/45.jpg,0,0,0,0,32,32
Warning: imagecopy(): supplied argument is not a valid Image resource in /home/lesmonde/public_html/admin/gen_map.php on line 74
Resource id #4 ,images/ville/53.jpg,32,0,0,0,32,32
etc ..
L'image existe bien, un <img> me la trouve bien.

Quelqu'un serait pourquoi ?

Merci.
MarcCC est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 18h03.


 
 
 
 
Partenaires

Hébergement Web