par
x@v » 29 oct. 2008, 16:49
$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.
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]$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;
} [/php]
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.
imagecreatetruecolor() ne fonctionne pas avec le format GIF.
http://fr.php.net/manual/fr/function.imagecreatetruecolor.php
Une solution médianne est nécessaire