날도 더운데 하루 웬종일 헤메고 있습니다.
GD라이브러리 이용해서 최근 이미지 썸내일 생성을 하는데,
죽어라 안되는 군효.
아래와 같은 에러 메세지와 계속 나와요.
Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/atns1324/public_html/Thumb_Engine/Thumb_latest_Engine01.php on line 10
처음에는 thumb_size.txt 파일이 게시판 스킨 폴더에 없다는 에러 메세지가 나오길래.
메모장에서 thumb_size.txt 파일 만들어서 스킨 폴더에 업로드 했거든요.
하고나니. 저런 에러 메세지가.. 0보다 커여 된다는 거같은데... 도대체 무슨 말인지..
웬종일 이곳을 찾아봐도 해결하지 못했습니다.
고수님도 제발.. 좀 도아 주세요!
참고로 Thumb_latest_Engine01.php 올립니다. ㅠㅠ
<?
// 최신글에서 썸네일 보여줄때 사용함 /skin/board/photo_thumb 폴더스킨과 연동됨.
// 두개이상의 '썸네일 최신글'을 불러오려면 본 파일을 파일명만 변경하여 추가.
// 최신글에서 썸네일 보여줄때 사용함 /skin/board/photo_thumb 폴더스킨과 연동됨.
// 두개이상의 '썸네일 최신글'을 불러오려면 본 파일을 파일명만 변경하여 추가.
/* 불러올 스킨폴더 지정 */
$board_skin_path = "$g4[path]/skin/board/gd_gallery_list";
$board_skin_path = "$g4[path]/skin/board/gd_gallery_list";
// 쎔네일 파일 최대 사이즈 파일에서 읽어와서 지정
$thum_filename = $board_skin_path . "/thumb_size.txt"; // 썸네일 최대폭 값을 처리하기 위해 파일로 처리
$fp_thum = fopen($thum_filename, "r"); $thum_max_size = fread($fp_thum, filesize($thum_filename));
fclose($fp_thum);
$thum_filename = $board_skin_path . "/thumb_size.txt"; // 썸네일 최대폭 값을 처리하기 위해 파일로 처리
$fp_thum = fopen($thum_filename, "r"); $thum_max_size = fread($fp_thum, filesize($thum_filename));
fclose($fp_thum);
global $max, $thum_W, $thum_H;
$noIMG = $latest_skin_path."/img/no_image.jpg"; //[필수](URL)
$noIMG = $board_skin_path."/img/no_image.jpg"; //[필수](URL)
$noIMG = $latest_skin_path."/img/no_image.jpg"; //[필수](URL)
$noIMG = $board_skin_path."/img/no_image.jpg"; //[필수](URL)
$max = $thum_max_size ; // [](픽셀) // 썸네일 이미지의 가로세로(긴쪽)의 최대치.
$resol = 80 ; // [](퍼센트%) // 생성되는 썸네일의 JPG압축률.
$resol = 80 ; // [](퍼센트%) // 생성되는 썸네일의 JPG압축률.
// ########## 썸네일 관련 함수 ###############################
function smaller( $W, $H ) {
global $max, $thum_W, $thum_H ;
global $max, $thum_W, $thum_H ;
if ( $W > $H ) { //가로형일 경우.
$thum_W = $max ;
$thum_H = ceil( $H * ( $max / $W ) );
}
if ( $W < $H ) { //세로형일 경우.
$thum_H = $max ;
$thum_W = ceil( $W * ( $max / $H ) );
}
if ( $W == $H ) { //정사각형일 경우.
$thum_W = ceil( $max * 0.8 );
$thum_H = ceil( $max * 0.8 );
}
return $thum_W ;
return $thum_H ;
}
$thum_W = $max ;
$thum_H = ceil( $H * ( $max / $W ) );
}
if ( $W < $H ) { //세로형일 경우.
$thum_H = $max ;
$thum_W = ceil( $W * ( $max / $H ) );
}
if ( $W == $H ) { //정사각형일 경우.
$thum_W = ceil( $max * 0.8 );
$thum_H = ceil( $max * 0.8 );
}
return $thum_W ;
return $thum_H ;
}
function maker( $thum_W, $thum_H ) {
global $thum, $resol, $ori, $ori_info ;
//$newImg = ImageCreate($thum_W,$thum_H); // GD라이브러리 2.0 (이하일 경우)
$newImg = ImageCreateTrueColor($thum_W,$thum_H); // GD라이브러리 2.0 전용함수
if($ori_info[2]=="1") $origImg=imagecreatefromgif($ori);
if($ori_info[2]=="2") $origImg=ImageCreateFromjpeg($ori);
if($ori_info[2]=="3") $origImg=ImageCreateFrompng($ori);
//if($ori_info[2]=="6") $origImg=imagecreatefromwbmp($ori);
//ImageCopyResized($newImg,$origImg,0,0,0,0,$thum_W,$thum_H,ImageSX($origImg),ImageSY($origImg));
imageCopyResampled($newImg,$origImg,0,0,0,0,$thum_W,$thum_H,ImageSX($origImg),ImageSY($origImg));
Imagejpeg($newImg, $thum, $resol );
chmod($thum,0707);
ImageDestroy($newImg);
ImageDestroy($origImg);
$newImg = ImageCreateTrueColor($thum_W,$thum_H); // GD라이브러리 2.0 전용함수
if($ori_info[2]=="1") $origImg=imagecreatefromgif($ori);
if($ori_info[2]=="2") $origImg=ImageCreateFromjpeg($ori);
if($ori_info[2]=="3") $origImg=ImageCreateFrompng($ori);
//if($ori_info[2]=="6") $origImg=imagecreatefromwbmp($ori);
//ImageCopyResized($newImg,$origImg,0,0,0,0,$thum_W,$thum_H,ImageSX($origImg),ImageSY($origImg));
imageCopyResampled($newImg,$origImg,0,0,0,0,$thum_W,$thum_H,ImageSX($origImg),ImageSY($origImg));
Imagejpeg($newImg, $thum, $resol );
chmod($thum,0707);
ImageDestroy($newImg);
ImageDestroy($origImg);
return $thum ;
}
// #########################################################
}
// #########################################################
?>
댓글을 작성하시려면 로그인이 필요합니다.
댓글 2개
이 함수 대신에 file이나 fgets를 고려해 보세요.
다음 내용도 참고 하세요.
http://kr.php.net/manual/kr/function.clearstatcache.php
그리고 thumb_size.txt 파일의 퍼미션을 707 인지 확인해 보세요