Je voudrai créer un script.php qui redimensionne une série d’images, quelqu’un saurait-il quel fonction je doit utiliser ?
Code : Tout sélectionner
<?php
// Le fichier
$filename = 'test.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);
?> Code : Tout sélectionner
<br />
<b>Fatal error</b>: Call to undefined function: imagecreatetruecolor() in <b>h:\WWW\redi.php</b> on line <b>15</b><br />Enlève le ";" en début de ligne, c'est une mise en commentaire, ensuite, relance Apache et refais ton test.;extension=php_gd2.dll