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 30 31
| $id = $_GET['id'];
$img_src_chemin = '../images/catal/'.$id.'.jpg';
$img_dst_chemin = '../images/catal/'.$id.'_zoom.jpg';
$img_dst_chemin_2 = '../images/catal/'.$id.'_thumb.jpg';
$img_src_resource = imagecreatefromjpeg( $img_src_chemin );
$img_src_resource_2 = imagecreatefromjpeg( $img_src_chemin );
$img_src_width = imagesx( $img_src_resource );
$img_src_height = imagesy( $img_src_resource );
if ($img_src_width < $img_src_height) {
$x = round((315*$img_src_width)/$img_src_height);
$x_2 = round((75*$img_src_width)/$img_src_height);
$img_dst_resource = imagecreatetruecolor( $x, 315 );
imagecopyresampled($img_dst_resource,$img_src_resource,0,0,0,0,$x,315,$img_src_width,$img_src_height);
$img_dst_resource_2 = imagecreatetruecolor( $x_2, 75 );
imagecopyresampled($img_dst_resource_2,$img_src_resource,0,0,0,0,$x_2,75,$img_src_width,$img_src_height);
}
else {
$y = round((315*$img_src_height)/$img_src_width);
$y_2 = round((75*$img_src_height)/$img_src_width);
$img_dst_resource = imagecreatetruecolor( 315, $y );
imagecopyresampled($img_dst_resource,$img_src_resource,0,0,0,0,315,$y,$img_src_width,$img_src_height);
$img_dst_resource_2 = imagecreatetruecolor( 75, $y_2 );
imagecopyresampled($img_dst_resource_2,$img_src_resource,0,0,0,0,75,$y_2,$img_src_width,$img_src_height);
}
imagejpeg( $img_dst_resource, $img_dst_chemin );
imagejpeg( $img_dst_resource_2, $img_dst_chemin_2 ); |
Partager