갤러리 썸네일 비율로 보이게 하는법 정보
갤러리 썸네일 비율로 보이게 하는법본문
댓글 전체
list.skin.php 썸네일 생성 부분에서 아래 점선 내부를 참고해서 수정해보세요.
가로나 세로 가운데 큰쪽을 설정된 사이즈로 마추고 작은쪽은 비율에 따라 줄여주는 방법입니다.
$dest_file = $data_path .'/'. $file;//원본 이미지
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($dest_file)){
$thumb = $thumb_path.'/' . $file;
if (!file_exists($thumb)) {
$size = getimagesize($dest_file);
if ($size[2] == 1)
$src = imagecreatefromgif($dest_file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($dest_file);
else if ($size[2] == 3)
$src = imagecreatefrompng($dest_file);
else
break;
//------------------------------------------------------------------------
if ($size[0] >= $size[1]) {
//최대 사이즈 제한 방식 - 가로 세로 최대 사이즈 bo_1에 입력
$rate = $board[bo_1] / $size[0];
$width = $board[bo_1];
$height = (int)($size[1] * $rate);
}
else {
$rate = $board[bo_1] / $size[1];
$width = (int)($size[0] * $rate);
$height = $board[bo_1];
}
//------------------------------------------------------------------------
$dst = imagecreatetruecolor($width, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
imagepng($dst, $thumb, $board['bo_2']);
chmod($thumb, 0707);
/*
//가로기준 세로는 비율대로 반영 - 원본
$rate = $board['bo_1'] / $size[0];
$height = (int)($size[1] * $rate);
$dst = imagecreatetruecolor($board['bo_1'], $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $board['bo_1'], $height, $size[0], $size[1]);
imagepng($dst, $thumb, $board['bo_2']);
chmod($thumb, 0707);
*/
}
}//if preg
가로나 세로 가운데 큰쪽을 설정된 사이즈로 마추고 작은쪽은 비율에 따라 줄여주는 방법입니다.
$dest_file = $data_path .'/'. $file;//원본 이미지
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($dest_file)){
$thumb = $thumb_path.'/' . $file;
if (!file_exists($thumb)) {
$size = getimagesize($dest_file);
if ($size[2] == 1)
$src = imagecreatefromgif($dest_file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($dest_file);
else if ($size[2] == 3)
$src = imagecreatefrompng($dest_file);
else
break;
//------------------------------------------------------------------------
if ($size[0] >= $size[1]) {
//최대 사이즈 제한 방식 - 가로 세로 최대 사이즈 bo_1에 입력
$rate = $board[bo_1] / $size[0];
$width = $board[bo_1];
$height = (int)($size[1] * $rate);
}
else {
$rate = $board[bo_1] / $size[1];
$width = (int)($size[0] * $rate);
$height = $board[bo_1];
}
//------------------------------------------------------------------------
$dst = imagecreatetruecolor($width, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
imagepng($dst, $thumb, $board['bo_2']);
chmod($thumb, 0707);
/*
//가로기준 세로는 비율대로 반영 - 원본
$rate = $board['bo_1'] / $size[0];
$height = (int)($size[1] * $rate);
$dst = imagecreatetruecolor($board['bo_1'], $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $board['bo_1'], $height, $size[0], $size[1]);
imagepng($dst, $thumb, $board['bo_2']);
chmod($thumb, 0707);
*/
}
}//if preg