Page 1 sur 1

Traitement d'image

Posté : 12 janv. 2006, 12:59
par vares2
Jaimerais avoir un script PHP qui me permettra de redimensionner mes images trop grandes mais qui conserve les proportions de l'image.

Merci

Posté : 12 janv. 2006, 13:06
par heddicmi

Posté : 12 janv. 2006, 13:22
par mario
http://fr2.php.net/manual/fr/function.i ... ampled.php

c'est dans la doc (Exemple 2. Redimensionnement proportionnel d'une image)

merci

Posté : 12 janv. 2006, 13:25
par vares2
merci pour ton aide

Traitement d'image

Posté : 12 janv. 2006, 14:39
par vares2
tres cher mario, merci pour ton script, jai copié l'exemple 2 dans un fichier et je l'ai exécuté mais sa ne marche pas, aide moi.


Le script: pic.php

<?php
// Le fichier
$filename = 'marie.jpg';

// Définition de la largeur et de la hauteur maximale
$width = 200;
$height = 200;

// Content type
header('Content-type: image/jpeg');

// Cacul des nouvelles dimensions
list($width_orig, $height_orig) = getimagesize($filename);

if ($width && ($width_orig < $height_orig)) {
$width = ($height / $height_orig) * $width_orig;
} else {
$height = ($width / $width_orig) * $height_orig;
}

// Redimensionnement
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

// Affichage
imagejpeg($image_p, null, 100);
?>



l'erreur:


<br />
<b>Fatal error</b>: imagecreatetruecolor(): requires GD 2.0 or later in <b>c:\program files\easyphp\www\abidjancell\pic.php</b> on line <b>22</b><br />




Merci pour ton aide precieuse

Re: Traitement d'image

Posté : 12 janv. 2006, 20:11
par Ic3Cub3
<b>Fatal error</b>: imagecreatetruecolor(): requires GD 2.0 or later in <b>c:\program files\easyphp\www\abidjancell\pic.php</b> on line <b>22</b><br />
Tout est dit là, il te faut la librairie GD2
Edite ton fichier PHP.INI
Il te suffit d'enlever le ; devant la ligne extension=php_gd2.dll si je ne me trompe