썸네일 안의 이미지 사이즈 조정 부탁드립니다. 채택완료
http://photossik88.cafe24.com/bbs/board.php?bo_table=1010">http://photossik88.cafe24.com/bbs/board.php?bo_table=1010
위 주소의 갤러리 이구요.
자세히 보시면 사진이 가운데에 위치해야하는데 썸네일의 사이즈 보다 조금 커서
왼쪽부터 맞춰집니다.
사진이 썸네일 지정한 크기인 240에 180으로 표시되게 하고싶은데요 강제적으로.
아래 skin.lib.php를 봐도 어딜 건드려야 할지모르겠네요ㅜㅜㅜㅜ
부탁좀드릴게요ㅜ
</p><p> </p><p><?</p><p>if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 </p><p> </p><p>if (!function_exists("makeThumbs")) {</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>function makeThumbs($oriPath, $oriFileName, $thmWidth="", $thmHeight="", $thmAlt="") {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>global $g4, $board_skin_path;</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$errorFilePrt = "<img src=\"".$board_skin_path."/img/noimage.gif\" border=\"0\" alt=\"이미지 없음\" />";</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$oriFile = $oriPath . "/" . $oriFileName;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if (is_file($oriFile) == false) return $errorFilePrt; // 원본 부재</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$thmPath = $oriPath . "/thumbs";</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$thmFile = $thmPath . "/" . $oriFileName;</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$oriSize = getimagesize($oriFile);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$oriWidth = $oriSize[0];</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$oriHeight = $oriSize[1];</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$oriType = $oriSize[2];</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($oriType > 3) return $errorFilePrt; // 원본 이미지 타입 오류</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$oriRate = $oriWidth / $oriHeight;</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($thmWidth == "" && $thmHeight == "") return $errorFilePrt; // 썸네일 사이즈 미지정</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($thmWidth == "") $thmWidth = $thmHeight * $oriRate;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($thmHeight == "") $thmHeight = $thmWidth / $oriRate;</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$widthRate = $thmWidth / $oriWidth;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$heightRate = $thmHeight / $oriHeight;</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$oriFilePrt = "<img src=\"".$oriFile."\" width=\"".$oriWidth."\" height=\"".$oriHeight."\" border=\"0\" alt=\"".$thmAlt."\" />";</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($widthRate >= 1 && $heightRate >= 1) return $oriFilePrt; // 리사이징 불필요</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if (file_exists($thmFile)) { // 썸네일 유무</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$fp = fopen($thmFile, "r");</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$fstat = fstat($fp);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$thmFileTime = $fstat['ctime'];</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>fclose($fp);</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$fp = fopen($oriFile, "r");</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$fstat = fstat($fp);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$oriFileTime = $fstat['ctime'];</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>fclose($fp);</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if (is_dir($oriPath . "/thumbs/")) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$array1 = $array2 = array();</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($dh = opendir($oriPath . "/thumbs/")) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>while (($file = readdir($dh)) !== false) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$array1[] = $file;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>closedir($dh);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($dh = opendir($oriPath . "/")) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>while (($file = readdir($dh)) !== false) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$array2[] = $file;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>closedir($dh);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$array_diff = array_diff($array1, $array2);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>foreach ($array_diff as $k => $v) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if (is_file($oriPath . "/thumbs/" . $v)) @unlink($oriPath . "/thumbs/" . $v);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$thmFileSize = getimagesize($thmFile);</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($thmWidth == $thmFileSize[0] && $thmHeight == $thmFileSize[1]) { // 썸네일 갱신 불필요</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($thmFileTime > $oriFileTime) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$thmSize = getimagesize($thmFile);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$thmFilePrt = "<img src=\"".$thmFile."\" width=\"".$thmSize[0]."\" height=\"".$thmSize[1]."\" border=\"0\" alt=\"".$thmAlt."\" />";</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>return $thmFilePrt;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>@unlink($thmFile);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>@mkdir($thmPath);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>@chmod($thmPath, 0707);</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($widthRate < $heightRate) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$tempWidth = (int)($oriWidth * $heightRate);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$tempHeight = $thmHeight;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>} else {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$tempWidth = $thmWidth;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$tempHeight = (int)($oriHeight * $widthRate);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($tempWidth == "") $tempWidth = $thmWidth;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($tempHeight == "") $tempHeight = $thmHeight;</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>switch($oriType) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>case(1) :</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if(function_exists('imagecreateFromGif')) $tempImage = imagecreateFromGif($oriFile);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>break;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>case(2) :</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if(function_exists('imagecreateFromJpeg')) $tempImage = imagecreateFromJpeg($oriFile);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>break;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>case(3) :</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if(function_exists('imagecreateFromPng')) $tempImage = imagecreateFromPng($oriFile);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>break;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($tempImage) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if (function_exists('imagecreatetruecolor')) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$tempCanvas = imagecreatetruecolor($thmWidth, $thmHeight);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>} else {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$tempCanvas = imagecreate($thmWidth, $thmHeight);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if (function_exists('imagecopyresampled')) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>imagecopyresampled($tempCanvas, $tempImage, 0, 0, 0, 0, $tempWidth, $tempHeight, ImageSX($tempImage), ImageSY($tempImage));</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>} else {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>imagecopyresized($tempCanvas, $tempImage, 0, 0, 0, 0, $tempWidth, $tempHeight, ImageSX($tempImage), ImageSY($tempImage));</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>ImageDestroy($tempImage);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>ImageJpeg($tempCanvas, $thmFile, 100);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>ImageDestroy($tempCanvas);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>unset($tempImage, $tempCanvas);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$thmFilePrt = "<img src=\"{$thmFile}\" width=\"{$thmWidth}\" height=\"{$thmHeight}\" border=\"0\" alt=\"{$thmAlt}\" />";</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>return $thmFilePrt;</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p>}</p><p>?> </p><p> </p><p>
답변 6개
위의 소스 86 - 92줄 까지를 아래와 같이 변경
</p><p> $srcX = 0;
$srcY = 0;</p><p> if ($widthRate < $heightRate) {
$tempWidth = (int)($oriWidth * $heightRate);
$tempHeight = $thmHeight;
$srcX = ceil(($tempWidth - $thmWidth)/($tempWidth/$oriWidth)/2);
} else {
$tempWidth = $thmWidth;
$tempHeight = (int)($oriHeight * $widthRate);
$srcY = ceil(($tempHeight - $thmHeight)/($tempHeight/$oriHeight)/2);
}</p><p>
위의 소스 116-120줄을 아래와 같이 변경
</p><p> if (function_exists('imagecopyresampled')) {
imagecopyresampled($tempCanvas, $tempImage, 0, 0, $srcX, $srcY, $tempWidth, $tempHeight, ImageSX($tempImage), ImageSY($tempImage));
} else {
imagecopyresized($tempCanvas, $tempImage, 0, 0, $srcX, $srcY, $tempWidth, $tempHeight, ImageSX($tempImage), ImageSY($tempImage));
}</p><p>
아마 기존 썸네일을 지우셔야 갱신되지 싶은데 함 해보세요.
요걸로 되야될건데...
댓글을 작성하려면 로그인이 필요합니다.
list.skin.php에서
가로세로 링크에서 섬네일링크를 업로드 링크로 변경처리도 해주세요
그래야 더 맑은 이미지를 걸수 있습니다.
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인