|
 |
15년 전 |
// 생성될 이미지의 가로 세로 비율
$B_width = 50;
$B_height = 100;
// 대상 이미지명
$srcimg = "tmp/nosundo.gif";
// 생성 이미지명
$tgtimg = "tmp/cropimg.gif";
$size = getimagesize($srcimg);
if($B_width * $size[1] < $B_height * $size[0])
{
// 원본 이미지의 가로크기가 지정 비율보다 크다.
$rs_img_width = round($size[1] * ($B_width / $B_height));
$rs_img_height = $size[1];
// 자를 시작 x,y좌표
$sc_x = round(($size[0] - $rs_img_width) / 2);
$sc_y = 0;
}
else
{
// 원본 이미지의 세로크기가 지정 비율보다 크다.
$rs_img_width = $size[0];
$rs_img_height = round($size[0] * ($B_height / $B_width));
// 자를 시작 x,y좌표
$sc_x = 0;
$sc_y = round(($size[1] - $rs_img_height) / 2);
}
// copyresampled 값이 동일하다 why? 이미지의 확대 축소가 발생하지는 않기 때문이다.
$sc_img_width = $rs_img_width;
$sc_img_height = $rs_img_height;
$rs_x =0;
$rs_y =0;
$sc_img = imagecreatefromgif($srcimg);
$rs_img = imagecreatetruecolor($rs_img_width, $rs_img_height);
imagecopyresampled($rs_img, $sc_img, $rs_x, $rs_y, $sc_x, $sc_y, $rs_img_width, $rs_img_height, $sc_img_width, $sc_img_height);
imagegif($rs_img, $tgtimg, 100);
imagedestroy($sc_img);
|
|
추천 : 607 |
추천
목록
|
|