불당썸 사용 최신글 엑박문제
본문
불당썸 사용최신글과 탭최신글 이미지 엑박이 나네요
data폴더안에 폴더생성은 되나 이미지파일이 생기질 않습니다.
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once("$g4[path]/lib/thumb.lib.php");
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb_neo';
$opts = explode("|",$options);
$img_cols=$opts[0];//가로 라인수
$img_width = $opts[1]; //갤러리형 썸네일 가로 크기
$img_height = $opts[2]; //갤러리형 썸네일 세로 크기
$img_quality = '99';
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff" style="padding-top:0px" align=center>
<tr>
<?
for ($i=0; $i<count($list); $i++)
{
$file = "$g4[path]/data/file/$bo_table/".$list[$i][file][0][file];
if (!file_exists($file) || !$list[$i][file][0][file]){//이미지가 없다면
$thumb = "$latest_skin_path/img/no_img.gif";
}else{
$thumb = thumbnail($file, $img_width, $img_height, 0, 1,$img_quality,"", $filter, $noimg); //언샾마스크추가
}
echo " <td valign=top>
<table width='99%' cellpadding='0' cellspacing='0' border='0' style='padding:0px;' >
<tr align=center>
<td style='padding-top:0px;'>
<table bgcolor='#ffffff' cellpadding='3' cellspacing='0' border='0' width='{$img_width}'>
<tr><td align='center' valign='middle' style='border:1px solid #cfcfcf'><a href='{$list[$i][href]}'>
<img src='{$thumb}' width='{$img_width}' height='{$img_height}' border='0' ></a></td>
</tr>
<tr><td height=8 align=center>{$list[$i][subject]}</td></tr>
</table>
</td>
</tr>
</table>
</td>
";
if($i !=0 && ($i+1)%$img_cols==0 &&( $i+1)<count($list)){
echo "</tr><tr>";
}
}
?>
</tr>
</table>
답변 1
썸네일 소스입니다
<?
// 원본 이미지를 넘기면 비율에 따라 썸네일 이미지를 생성함
// 가로, 세로, 파일경로, 생성경로, true
function createThumb($imgWidth, $imgHeight, $imgSource, $imgThumb='', $iscut=false)
{
if (!$imgThumb)
$imgThumb = $imgSource;
$size = getimagesize($imgSource);
if ($size[2] == 1)
$source = imagecreatefromgif($imgSource);
else if ($size[2] == 2)
$source = imagecreatefromjpeg($imgSource);
else if ($size[2] == 3)
$source = imagecreatefrompng($imgSource);
else
continue;
$rate = $imgWidth / $size[0];
$height = (int)($size[1] * $rate);
if ($height < $imgHeight) {
$target = @imagecreatetruecolor($imgWidth, $height);
} else {
$target = @imagecreatetruecolor($imgWidth, $imgHeight);
}
@imagecopyresampled($target, $source, 0, 0, 0, 0, $imgWidth, $height, $size[0], $size[1]);
@imagejpeg($target, $imgThumb, 100);
@chmod($imgThumb, 0606); // 추후 삭제를 위하여 파일모드 변경
}
// 프로그램 : 불당썸 2.0.x
// 개 발 자 : 아빠불당 (www.webdevlogs.com
//V 1.0
if(!function_exists('imagefilter')){
function imagefilter($source, $var, $arg1 = null, $arg2 = null, $arg3 = null){
#define('IMAGE_FILTER_NEGATE',0);
#define('IMAGE_FILTER_GRAYSCALE',0);
#define('IMAGE_FILTER_BRIGHTNESS',2);
#define('IMAGE_FILTER_CONTRAST',3);
#define('IMAGE_FILTER_COLORIZE',4);
#define('IMAGE_FILTER_EDGEDETECT',5);
#define('IMAGE_FILTER_EMBOSS',6);
#define('IMAGE_FILTER_GAUSSIAN_BLUR',7);
#define('IMAGE_FILTER_SELECTIVE_BLUR',8);
#define('IMAGE_FILTER_MEAN_REMOVAL',9);
#define('IMAGE_FILTER_SMOOTH',10);
$max_y = imagesy($source);
$max_x = imagesx($source);
switch ($var){
case 0:
$y = 0;
while($y<$max_y) {
$x = 0;
while($x<$max_x){
$rgb = imagecolorat($source,$x,$y);
$r = 255 - (($rgb >> 16) & 0xFF);
$g = 255 - (($rgb >> 8) & 0xFF);
$b = 255 - ($rgb & 0xFF);
$a = $rgb >> 24;
$new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a);
if ($new_pxl == false){
$new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a);
}
imagesetpixel($source,$x,$y,$new_pxl);
++$x;
}
++$y;
}
return true;
break;
case 1:
$y = 0;
while($y<$max_y) {
$x = 0;
while($x<$max_x){
$rgb = imagecolorat($source,$x,$y);
$a = $rgb >> 24;
$r = ((($rgb >> 16) & 0xFF)*0.299)+((($rgb >> 8) & 0xFF)*0.587)+(($rgb & 0xFF)*0.114);
$new_pxl = imagecolorallocatealpha($source, $r, $r, $r, $a);
if ($new_pxl == false){
$new_pxl = imagecolorclosestalpha($source, $r, $r, $r, $a);
}
imagesetpixel($source,$x,$y,$new_pxl);
++$x;
}
++$y;
}
return true;
break;
case 2:
$y = 0;
while($y<$max_y) {
$x = 0;
while($x<$max_x){
$rgb = imagecolorat($source,$x,$y);
$r = (($rgb >> 16) & 0xFF) + $arg1;
$g = (($rgb >> 8) & 0xFF) + $arg1;
$b = ($rgb & 0xFF) + $arg1;
$a = $rgb >> 24;
$r = ($r > 255)? 255 : (($r < 0)? 0:$r);
$g = ($g > 255)? 255 : (($g < 0)? 0:$g);
$b = ($b > 255)? 255 : (($b < 0)? 0:$b);
$new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a);
if ($new_pxl == false){
$new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a);
}
imagesetpixel($source,$x,$y,$new_pxl);
++$x;
}
++$y;
}
return true;
break;
case 3:
$contrast = pow((100-$arg1)/100,2);
$y = 0;
while($y<$max_y) {
$x = 0;
while($x<$max_x){
$rgb = imagecolorat($source,$x,$y);
$a = $rgb >> 24;
$r = (((((($rgb >> 16) & 0xFF)/255)-0.5)*$contrast)+0.5)*255;
$g = (((((($rgb >> 8) & 0xFF)/255)-0.5)*$contrast)+0.5)*255;
$b = ((((($rgb & 0xFF)/255)-0.5)*$contrast)+0.5)*255;
$r = ($r > 255)? 255 : (($r < 0)? 0:$r);
$g = ($g > 255)? 255 : (($g < 0)? 0:$g);
$b = ($b > 255)? 255 : (($b < 0)? 0:$b);
$new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a);
if ($new_pxl == false){
$new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a);
}
imagesetpixel($source,$x,$y,$new_pxl);
++$x;
}
++$y;
}
return true;
break;
case 4:
$x = 0;
while($x<$max_x){
$y = 0;
while($y<$max_y){
$rgb = imagecolorat($source, $x, $y);
$r = (($rgb >> 16) & 0xFF) + $arg1;
$g = (($rgb >> 8) & 0xFF) + $arg2;
$b = ($rgb & 0xFF) + $arg3;
$a = $rgb >> 24;
$r = ($r > 255)? 255 : (($r < 0)? 0:$r);
$g = ($g > 255)? 255 : (($g < 0)? 0:$g);
$b = ($b > 255)? 255 : (($b < 0)? 0:$b);
$new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a);
if ($new_pxl == false){
$new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a);
}
imagesetpixel($source,$x,$y,$new_pxl);
++$y;
}
++$x;
}
return true;
break;
case 5:
return imageconvolution($source, array(array(-1,0,-1), array(0,4,0), array(-1,0,-1)), 1, 127);
break;
case 6:
return imageconvolution($source, array(array(1.5, 0, 0), array(0, 0, 0), array(0, 0, -1.5)), 1, 127);
break;
case 7:
return imageconvolution($source, array(array(1, 2, 1), array(2, 4, 2), array(1, 2, 1)), 16, 0);
break;
case 8:
for($y = 0; $y<$max_y; $y++) {
for ($x = 0; $x<$max_x; $x++) {
$flt_r_sum = $flt_g_sum = $flt_b_sum = 0;
$cpxl = imagecolorat($source, $x, $y);
for ($j=0; $j<3; $j++) {
for ($i=0; $i<3; $i++) {
if (($j == 1) && ($i == 1)) {
$flt_r[1][1] = $flt_g[1][1