이미지를 지정된 비율로 자르기 (crop) | |||
| |||
$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); Tags: GDI+ PHP crop image 윈도우즈 | |||
| |||
| |||
로그인을 하시면 댓글을 등록 할 수 있습니다. |
SIMILAR POSTS 구글 메일(GMail)로 메일 발송하기 |
OTHER POSTS IN THE SAME CATEGORY 초간단 php-oracle 연동 클래스 |