Bonjour,
dans mon code qui permet de redimenssionner des images, j'obtiens des erreurs.
Voici le code de mes fichiers:
index.html
index2.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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>
Voici les erreurs:
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 <?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); ?>
Code X : Sélectionner tout - Visualiser dans une fenêtre à part
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.
Partager