1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| function ImageResize($pImage, $t_width, $t_height)
{
$iCanvas = @ImageCreateTrueColor($t_width, $t_height);
$s_width = ImageSX($pImage);
$s_height = ImageSY($pImage);
ImageCopyResampled($iCanvas, $pImage, 0, 0, 0, 0, $t_width, $t_height, $s_width, $s_height);
return $iCanvas;
}
function Vignette($source, $destination, $x = 100, $y = 100) // réduction sans dénaturation de l'image
{
$img = imagecreatefromjpeg($source);
if(!$img) return false;
$xx = ImageSX($img);
$yy = ImageSY($img);
if($xx / $yy > $x / $y)
{ // réduction sur X
$f = $y / $xx;
$rX = $xx * $f;
$rY = $yy * $f;
}
else
{ // réduction sur Y
$f = $x / $yy;
$rX = $xx * $f;
$rY = $yy * $f;
}
imagejpeg(ImageResize($img, $rX, $rY), $destination);
} |
Partager