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 17/02/2007, 20h22   #1
Membre régulier
 
Étudiant
Inscription : juillet 2006
Messages : 147
Détails du profil
Informations personnelles :
Âge : 28
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juillet 2006
Messages : 147
Points : 75
Points : 75
Envoyer un message via MSN à Henry9 Envoyer un message via Yahoo à Henry9
Par défaut Redimension d'image - plusieurs erreurs dans mon script

Bonjour,

dans mon code qui permet de redimenssionner des images, j'obtiens des erreurs.
Voici le code de mes fichiers:

index.html
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
<html>
<head><title>Upload d image</title></head>
<body>
 
<!-- création du formulaire -->
<form enctype="multipart/form-data" method="POST" action="index2.php">
<p>Votre image : <br>
<input type="file" name="image" size="20"><br>
<input type="submit" name="envoi" value="ok">
</p>
</form>
</body>
</html>
index2.php
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
$img = imagecreatefromjpeg ($_FILES['image']['tmp_name']);
$size = getimagesize($_FILES['image']['tmp_name']);
$larg=$size[0];
$long=$size[1];
$larg = $larg*20/100;
$long = $long*20/100;
$img_dest=imagecreatetruecolor($larg,$long);
 
 
$copy = imagecopyresampled($img_dest, $img, 0, 0, 0, 0, $larg, $long, $size[0], $size[1]);
 
header('Content-type: image/jpeg');
 
$fichier=$_FILES['image']['name'];
 
imagejpeg($img_dest);
imagejpeg($img_dest, 'image/'.$fichier);
 
imagedestroy($img_dest);
 
?>
Voici les erreurs:
Code X :
1
2
3
4
5
6
7
8
9
10
11
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\test\index2.php on line 8

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\test\index2.php on line 11

Warning: Cannot modify header information - headers already sent by (output started at C:\test\index2.php:8) in C:\test\index2.php on line 13

Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\test\index2.php on line 17

Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\test\index2.php on line 18

Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\test\index2.php on line 20

Pourtant, lorsque j'affiche dans firefox, le redimensionnement marche bien sans erreur.

J'utilise zend studio et j'ai activé la librairie gd dans php.ini

Merci d'avance pour votre aide.
Henry9 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/02/2007, 10h58   #2
Invité régulier
 
Inscription : mars 2006
Messages : 46
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 46
Points : 6
Points : 6
est ce que tes images sont bien en jpg ca m'est deja arrivé
zakuza 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 04h17.


 
 
 
 
Partenaires

Hébergement Web