썸네일 생성 질문입니다. 정보
썸네일 생성 질문입니다.
본문
기존에 썸네일 생성하는 코드들은 첫번째 파일을 기준으로 했자나요
저는 파일이 10개 있는데
이파일을 뷰화면에서 10개 다 보여줄려니 트래픽이 많이나와서
뷰화면에서
10개 모두 썸네일을 만들어줘서
보여주고 싶은데
잘안되네요
도움좀 부탁드립니다.
view 화면서 첫번째 섬네일 생성 하는건 이겁니다.
$img_width = 90;
$img_height = 60;
$img_quality = 95;
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
$img = "<img src='$board_skin_path/img/noimg.gif' width='$img_width' height='$img_height' title='이미지 없음' border=0 style='border:1px solid #CCCCCC; padding:3px;'>";
$thumb = $thumb_path.'/'.$view[wr_id];
$thumb2 = $data_path.'/'.$view[file][0][file];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
$file = $view[file][0][path] .'/'. $view[file][0][file];
// 업로드된 파일이 이미지라면
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
break;
$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/'.$view[wr_id], $img_quality);
chmod($thumb_path.'/'.$view[wr_id], 0606);
}
}
if (file_exists($thumb))
$img = "<a href='$thumb2' class='highslide' onclick='return hs.expand(this)' onfocus='this.blur();'><img src='$thumb' border=0 style='border:1px solid #CCCCCC; padding:3px;'></a>";
else
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file))
{ $img = "<script>doc_write(flash_movie('$file', 'flash$i', '$img_width', '$img_height', 'transparent'));</script>"; }
저는 파일이 10개 있는데
이파일을 뷰화면에서 10개 다 보여줄려니 트래픽이 많이나와서
뷰화면에서
10개 모두 썸네일을 만들어줘서
보여주고 싶은데
잘안되네요
도움좀 부탁드립니다.
view 화면서 첫번째 섬네일 생성 하는건 이겁니다.
$img_width = 90;
$img_height = 60;
$img_quality = 95;
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
$img = "<img src='$board_skin_path/img/noimg.gif' width='$img_width' height='$img_height' title='이미지 없음' border=0 style='border:1px solid #CCCCCC; padding:3px;'>";
$thumb = $thumb_path.'/'.$view[wr_id];
$thumb2 = $data_path.'/'.$view[file][0][file];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
$file = $view[file][0][path] .'/'. $view[file][0][file];
// 업로드된 파일이 이미지라면
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
break;
$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/'.$view[wr_id], $img_quality);
chmod($thumb_path.'/'.$view[wr_id], 0606);
}
}
if (file_exists($thumb))
$img = "<a href='$thumb2' class='highslide' onclick='return hs.expand(this)' onfocus='this.blur();'><img src='$thumb' border=0 style='border:1px solid #CCCCCC; padding:3px;'></a>";
else
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file))
{ $img = "<script>doc_write(flash_movie('$file', 'flash$i', '$img_width', '$img_height', 'transparent'));</script>"; }
댓글 전체
$thumb = $thumb_path.'/'.$view[wr_id];
이렇게 하면 썸네일이 하나만 하겠다는 것이니까
$thumb01 = $thumb_path.'/'.$view[wr_id].'_01';
$thumb02 = $thumb_path.'/'.$view[wr_id].'_02';
...
..
.
가 되도록 loop를 돌리세요.
이렇게 하면 썸네일이 하나만 하겠다는 것이니까
$thumb01 = $thumb_path.'/'.$view[wr_id].'_01';
$thumb02 = $thumb_path.'/'.$view[wr_id].'_02';
...
..
.
가 되도록 loop를 돌리세요.
루프 돌렸을시
Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 13056 bytes) in /home/hosting_users/doctorwash/www/car/skin/board/car/view.skin.php on line 127
이런 에러가 나오는데 무슨 이유일가요?
Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 13056 bytes) in /home/hosting_users/doctorwash/www/car/skin/board/car/view.skin.php on line 127
이런 에러가 나오는데 무슨 이유일가요?
잘 이해가 --
정확히 어떤걸 추가해줘야 할가요?
정확히 어떤걸 추가해줘야 할가요?
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/'.$view[wr_id], $img_quality);
chmod($thumb_path.'/'.$view[wr_id], 0606);
이렇게 하나 만들고 나서
imagedestroy( $src);
imagedestroy( $dst);
이렇게 해 주는 것인데
이렇게 해도 같은 에러라면
원래 php에 설정할 메모리가 부족하거나 이미지 사이즈가 큰 경우입니다.
imagepng($dst, $thumb_path.'/'.$view[wr_id], $img_quality);
chmod($thumb_path.'/'.$view[wr_id], 0606);
이렇게 하나 만들고 나서
imagedestroy( $src);
imagedestroy( $dst);
이렇게 해 주는 것인데
이렇게 해도 같은 에러라면
원래 php에 설정할 메모리가 부족하거나 이미지 사이즈가 큰 경우입니다.