La manip est plus simple à faire avec Fireworks par exemple, mais bon si tu as Photoshop ça te fera l'occasion d'apprendre une fonctionnalité de plus. Et si tu ne trouve pas facilement il devrait bien y avoir quelques tutos à ce sujet sur google
$t_image_p = imagecreatetruecolor($t_width, $t_height);
$t_quality = 80;
switch($extension)
{
case 'jpeg':
case 'jpg':
$t_image = imagecreatefromjpeg($fileTmpPath);
imagecopyresampled($t_image_p, $t_image, 0, 0, 0, 0, $t_width, $t_height, $width_orig, $height_orig);
imagejpeg($t_image_p, $t_filePath, $t_quality);
break;
case 'png':
$t_image = imagecreatefrompng($fileTmpPath);
imagecopyresampled($t_image_p, $t_image, 0, 0, 0, 0, $t_width, $t_height, $width_orig, $height_orig);
imagepng($t_image_p, $t_filePath, $t_quality);
break;
case 'gif':
$image = imagecreatefromgif($fileTmpPath);
imagecopyresampled($t_image_p, $t_image, 0, 0, 0, 0, $t_width, $t_height, $width_orig, $height_orig);
imagegif($t_image_p, $t_filePath, $t_quality);
break;
}
Cette solution est sympas sur le papier mais en terme de ressource imagecopyresampled() est une des fonction qui fait le plus de calcul, suicidaire pour l'affichage d'une page.
Tu as oublié que c'était uniquement lors de l'upload ? Et puis il est impossible (sinon je demande à voir comment) de faire du redimensionnement d'image avec une qualité correcte sans utiliser imagecopyresampled().Cette solution est sympas sur le papier mais en terme de ressource imagecopyresampled() est une des fonction qui fait le plus de calcul, suicidaire pour l'affichage d'une page.$t_image_p = imagecreatetruecolor($t_width, $t_height); $t_quality = 80; switch($extension) { case 'jpeg': case 'jpg': $t_image = imagecreatefromjpeg($fileTmpPath); imagecopyresampled($t_image_p, $t_image, 0, 0, 0, 0, $t_width, $t_height, $width_orig, $height_orig); imagejpeg($t_image_p, $t_filePath, $t_quality); break; case 'png': $t_image = imagecreatefrompng($fileTmpPath); imagecopyresampled($t_image_p, $t_image, 0, 0, 0, 0, $t_width, $t_height, $width_orig, $height_orig); imagepng($t_image_p, $t_filePath, $t_quality); break; case 'gif': $image = imagecreatefromgif($fileTmpPath); imagecopyresampled($t_image_p, $t_image, 0, 0, 0, 0, $t_width, $t_height, $width_orig, $height_orig); imagegif($t_image_p, $t_filePath, $t_quality); break; }
imagecreatetruecolor() ne fonctionne pas avec le format GIF.
http://fr.php.net/manual/fr/function.im ... ecolor.php
Une solution médianne est nécessaire
<?php
function fill_callback($image, $w, $h)
{
WdImage::drawGrid
(
$image, 0, 0, $w - 1, $h - 1
);
}
$thumbnail = WdImage::resize
(
$source,
$target_width,
$target_height,
WdImage::RESIZE_SCALE_MAX,
'fill_callback'
);
?>
Qui donne un truc du genre (avec trois images témoins) :