회원사진을 올리면서 썸네일 생성과정중에 > 그누4 질문답변

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

회원사진을 올리면서 썸네일 생성과정중에 정보

회원사진을 올리면서 썸네일 생성과정중에

본문

 

if (!defined("_GNUBOARD_")) exit;
include_once ("$g4[path]/lib/thumb.lib.php");
// 회원 이미지 삭제
$mPhoto_image_path = "{$g4['path']}/data/mPhoto_image/{mb_id}";
// 회원 썸네일 삭제
$mPhoto_thumb_path = "{$g4['path']}/data/mPhoto_image/thumb/{mb_id}.s_thumb";
$mPhoto_thumb_path2 = "{$g4['path']}/data/mPhoto_image/thumb/{mb_id}.l_thumb";


if( file_exists($mPhoto_image_path) && $mPhoto_image_del ) {
@unlink($mPhoto_image_path);
@unlink($mPhoto_thumb_path);
@unlink($mPhoto_thumb_path2);
}

// 회원 이미지 체크
$mPhoto_image = $_FILES['mPhoto_image']['tmp_name'];
$mPhoto_image_size = $_FILES['mPhoto_image']['size'];


if( $mPhoto_image_size ) {
// 가로 사이즈
$mPhoto_image_width = "1024";
// 세로 사이즈
$mPhoto_image_height = "768";
// 크기
$mPhoto_image_size = "1048576";
// 이미지 가로, 세로 및 mime 정보 로드
$get_image_size = getimagesize($mPhoto_image);

// 정보가 없을 경우 이미지가 아님
if( empty($get_image_size) )
alert("이미지 파일만 업로드 가능합니다.");

// MINE 값을 검사하여 PNG, GIF, JPG 만 업로드 가능하게 함
$image_type = array('image/png', 'image/jpeg', 'image/gif');

if( !in_array($get_image_size['mime'], $image_type) )
alert("회원 이미지는 jpg, gif, png 형식만 업로드 가능합니다.".$get_image_size['mime']);
if( $mPhoto_image_size != 0 && $mPhoto_image_size > $mPhoto_image_size )
alert("회원 이미지의 용량이 ".number_format($mPhoto_image_size)." byte 보다 큽니다.");
$mPhoto_image_path = "{$g4['path']}/data/mPhoto_image";
if( !is_dir($mPhoto_image_path) )
alert('디렉토리가 존재하지 않습니다.');

$mPhoto_image_file = "{$mPhoto_image_path}/{mb_id}";

//썸네일 생성
make_thumb(120, 80, $mPhoto_image_file, $mPhoto_thumb_path2);
make_thumb(40, 30, $mPhoto_image_file, $mPhoto_thumb_path);

// 업로드가 안된다면 에러메세지 출력하고 죽어버립니다.
$error_code = move_uploaded_file($mPhoto_image, $mPhoto_image_file) or die($_FILES['mPhoto_image']['error']);

// 올라간 파일의 퍼미션을 변경합니다.
chmod($mPhoto_image_file, 0606);
}
?>
유아원님 활용팁으로 회원사진을 업로드해서 쓰고있는데요 조금 수정을해서 썸네일을 같이 생성하게끔 사용하고 있습니다.
정보수정을 할때 이미 사진이 있는상태에서 또다시 사진을 업로드하게 되면 원본 이미지는 변경되는데 반해 썸네일은 전것이 남아있던데요. 새로운 이미지 업로드시 썸네일도 갱신이 되도록 하려 합니다. 조언좀 부탁드립니다

댓글 전체

make_thumb()함수에서 썸네일이 존재하면 새로이 만들지 않도록 되어있는 모양인데
그 부분을 수정해야 합니다
위 소스로는 아무것도 할 수 있는 것이 없습니다
Dq님 썸네일 엔진을 사용중인데 한번 봐주시겟어요?? dq님 홈페이지 갔더니 엔진관련 자료는 없어졌더라구요;;


<?
/*--------------------------------------------------------------------------------------------------------------

 ■ DQ'Thumb Engine ver 2.0 R5.0306

최종 수정: 2005-03-06
제작    : 드림퀘스트(본명:안현우)
Homepage : http://www.dqstyle.com
E-Mail  : www.가 포함되었을때의 처리
if(!@eregi("www.",$_SERVER[HTTP_HOST]) && eregi("www.",$tag_str)) {
$tag_str=str_replace("www.","",$tag_str);
$tag_str=get_indexDir()."/".eregi_replace($HH."/","",eregi_replace("http://","",$tag_str));
} elseif(eregi("www.",$_SERVER[HTTP_HOST]) && !eregi("www.",$tag_str)) {
$tag_str=get_indexDir()."/".eregi_replace($HH."/","",eregi_replace("http://","",$tag_str));
} else $tag_str=get_indexDir()."/".eregi_replace($_SERVER[HTTP_HOST]."/","",eregi_replace("http://","",$tag_str));

if(file_exists($tag_str))
$filename = make_thumb($thumb_x,$thumb_y,$tag_str,$target_file);
else $filename = "";
if(file_exists($filename)) return($filename); else return("");
}

$_fThumbWorkFile = $target_file.".work";
$fp = fopen($_fThumbWorkFile, "w");
fwrite($fp, "Get remote image works file");
fclose($fp);

if($dqEngine['using_socket']) {
  // 소켓 방식으로 시도
$str_info = parse_url($tag_str);
$str_info['port'] = $str_info['port'] ? $str_info['port'] : 80;
$fp=@fsockopen($str_info['host'],$str_info['port']);
if($fp) {
fputs($fp,"GET $str_info[path] HTTP/1.1\r\n");
fputs($fp,"Host: $str_info[host]\r\n");
fputs($fp,"User-Agent: Mozilla/4.0\r\n\r\n");

while(trim($buffer = fgets($fp,128)) != "") {
if(eregi('Content-Type: ',$buffer)) $header = $buffer;
}
//set_time_limit(30);
//socket_set_blocking($fp,false);
$urlfile_is_image = '1';
while(!feof($fp) && connection_status()==0) $urlFile .= fread($fp,1024);
}
} else {
// url_fopen 으로 시도
$fp=@fopen($tag_str, "r");
$urlfile_is_image = '1';
if($fp) {
while(!feof($fp) && connection_status()==0) {
$urlFile = $urlFile.fread($fp,1024);
}
}
}
if($fp) fclose($fp);
unlink($_fThumbWorkFile);

// 임시파일 저장
if($fp && $urlfile_is_image) {
$_thumb_temp = tempnam("./data", "thumb_temp_");

$fp = fopen($_thumb_temp, "w");
fwrite($fp, $urlFile);
fclose($fp);

$filename = make_thumb($thumb_x,$thumb_y,$_thumb_temp,$target_file);
if (!file_exists($filename)) $filename="";
$rt_str = $filename;
}

if(file_exists($_thumb_temp)) @unlink($_thumb_temp);
return $rt_str;
} else {
if(file_exists($target_file)) return $target_file;
else return;
}
}

// 생성될 섬네일 이미지의 크기계산
function cal_thumb_size($src_file, $max_x,$max_y) {
global $dqEngine;

static $oldInfo = array();
if($src_file == $oldInfo[3] && $max_x == $oldInfo[0] && $max_y == $oldInfo[1]) {
$cal_size = $oldInfo;
return $cal_size;
}

$img_info = @getimagesize ($src_file);
$sx = $img_info[0];
$sy = $img_info[1];

// 원본 이미지에 문제가 있다면 중단
if(!$src_file || !$sx || !$sy) return false;

if(!$dqEngine['gd_version'] && $dqEngine['thumb_resize'] > 0) $dqEngine['thumb_resize'] = 0;

switch($dqEngine['thumb_resize']) {
case 0: // 원본의 비율대로 대칭 리사이즈
if($max_x != 0 && $max_y != 0) {
if($sx>$sy) {
$cal_size[1]=ceil(($sy*$max_x)/$sx);
$cal_size[0]=$max_x;
if($cal_size[1] > $max_y) {
$cal_size[0]=ceil($sx*$max_y/$sy);
$cal_size[1]=$max_y;
}
}else {
$cal_size[0]=ceil($sx*$max_y/$sy);
$cal_size[1]=$max_y;
if($cal_size[0] > $max_x) {
$cal_size[1]=ceil($sy*$max_x/$sx);
$cal_size[0]=$max_x;
}
}
}

if($max_x==0 || $max_y==0) {
$tmp_y=ceil(($sy*$max_x)/$sx);
$tmp_x=ceil(($sx*$max_y)/$sy);
if($max_x>$max_y) {
if($sy>$tmp_y) $cal_size[1]=$tmp_y; else $cal_size[1]=$sy;
if($sx>$max_x) $cal_size[0]=$max_x; else $cal_size[0]=$sx;
}else {
if($sx>$tmp_x) $cal_size[0]=$tmp_x; else $cal_size[0]=$sx;
if($sy>$max_y) $cal_size[1]=$max_y; else $cal_size[1]=$sy;
}
}
break;

case 1:  // 지정된 크기로 리사이즈 한다.
$cal_size[0] = $max_x;
$cal_size[1] = $max_y;
break;

case 2:  // 원본리사이즈를 하면서 지정한 사이즈에 꽉 차는 이미지를 만들고 나머지는 잘라낸다.
$cal_size[0] = $max_x;
$cal_size[1] = $max_y;
if($sx == $sy) {
if($max_x>$max_y) $cal_size[5] = $max_x;
else $cal_size[4] = $max_y;
} else {
if($sx>$sy && $max_x>$max_y) {$org_y=$max_y; $max_y = 0;}
elseif($sx<$sy && $max_x<$max_y) {$org_x=$max_x; $max_x = 0;}
else {
if($sx>$sy) {$org_x=$max_x; $max_x = 0;}
if($sx<$sy) {$org_y=$max_y; $max_y = 0;}
}

if($max_x==0 || $max_y==0) {
$tmp_y=ceil(($sy*$max_x)/$sx);
$tmp_x=ceil(($sx*$max_y)/$sy);

if($tmp_y < $org_y) {
$tmp_y = $org_y;
$org_x=$max_x; $max_x = 0;
$tmp_x=ceil(($sx*$org_y)/$sy);
} elseif($tmp_x < $org_x) {
$tmp_x = $org_x;
$org_y=$max_y; $max_y = 0;
$tmp_y=ceil(($sy*$org_x)/$sx);
}
if($max_x>$max_y) {
if($sy>$tmp_y || $max_y<$tmp_y) $cal_size[5]=$tmp_y; else $cal_size[5]=$sy;
if($sy<$tmp_y) $cal_size[5]=$tmp_y;
if($sx<$max_x) $cal_size[4]=$tmp_x;
}else {
if($sx>$tmp_x || $max_x<$tmp_x) $cal_size[4]=$tmp_x; else $cal_size[4]=$sx;
if($sx<$tmp_x) $cal_size[4]=$tmp_x;
if($sy<$tmp_y) $cal_size[5]=$tmp_y;
}
}
break;
}
}

$cal_size[3]=$src_file;
$oldInfo = $cal_size;
return $cal_size;
}

// 섬네일을 생성해야 할 파일인지 검사
function chk_imgfile($src_file,$thumb_x,$thumb_y) {
$new_file=true;
if (file_exists($src_file)) {
$old_img = @getimagesize($src_file);
$cal_size = cal_thumb_size($src_file, $thumb_x, $thumb_y);
if ($old_img[0]!=$cal_size[0]) $tmp++;
if ($old_img[1]!=$cal_size[1]) $tmp++;
if ($tmp>0) $new_file=true; else $new_file=false;

if(!$old_img[0] || !$old_img[1]) $new_file=true;
}
$workFile = $src_file.".work";
if(file_exists($workFile)) $new_file = false;
return $new_file;
}

// allow_url_open 켬
function set_URLOpen($value) {
if($value==1) @ini_set("allow_url_fopen","1");
if($value==0) @ini_set("allow_url_fopen","0");
}


// 업로드된 이미지 목록을 배열로 저장해서 반환
function get_uploadImages($data, $max_no='99', $all='0') {
global $id;

$count=0;
$max_upload = 99;

if($all) $chk = '1';

$m_data=@mysql_fetch_array(mysql_query("select * from dq_revolution where zb_id='$id' and zb_no='$data[no]'"));

if($all) $chk = $data[file_name1] ? true : false; else $chk = (eregi("\.thumb|\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.wmf",$data[s_file_name1]) ? true : false);
if($chk && file_exists($data[file_name1])) {
$images[$count] = $data[file_name1];
$s_images[$count] = $data[s_file_name1];
$images_size[$count] = GetFileSize(filesize($data[file_name1]));
$images_count[$count] = 0;
$count++;
if($count==$max_no) $flag=1;
}

if($all) $chk = $data[file_name2] ? true : false; else $chk = (eregi("\.thumb|\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.wmf",$data[s_file_name2]) ? true : false);
if(!$flag && $chk && file_exists($data[file_name2])) {
$images[$count] = $data[file_name2];
$s_images[$count] = $data[s_file_name2];
$images_size[$count] = GetFileSize(filesize($data[file_name2]));
$images_count[$count] = 1;
$count++;
if($count==$max_no) $flag=1;
}

//업로드 확장기에 의한 파일목록 가져옴
/*
if(!$flag && $m_data[file_names]) {
$tmp_files = explode(",",$m_data[file_names]);
$tmp_sfiles = explode(",",$m_data[s_file_names]);

for($i=0; $i<$max_upload; $i++) {
if(eregi("\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.wmf",$tmp_files[$i])) {
$images[$count] = $tmp_files[$i];
$s_images[$count] = $tmp_sfiles[$i];
$images_size[$count] = GetFileSize(filesize($tmp_files[$i]));
$images_count[$count] = $i+2;
$count++;
$max_files = $count;
}
if($count==$max_no) $flag=1;
if($flag) break;
}
}
*/

$ret[0] = $images;
$ret[1] = $s_images;
$ret[2] = $images_size;
$ret[3] = $images_count;
//$ret[is_vdel] = $m_data[is_vdel];

return $ret;
}


//문서에서 제로보드 그림창고 태그 변환하기
function convt_imagebox($tmp, $ismember) {
global $_zb_url, $PHP_SELF, $_SERVER;

if($_zb_url) $_zboard_url = $_zb_url;
else $_zboard_url = "http://".$_SERVER[HTTP_HOST].str_replace(basename($PHP_SELF),"",$PHP_SELF);

$imageBoxPattern = "/\[img\:(.+?)\.(jpg|gif)\,align\=([a-z]){0,}\,width\=([0-9]+)\,height\=([0-9]+)\,vspace\=([0-9]+)\,hspace\=([0-9]+)\,border\=([0-9]+)\]/i";
$tmp=preg_replace($imageBoxPattern,"<img src=$_zboard_url"."icon/member_image_box/$ismember/\\1>", stripslashes($tmp));
$tmp=str_replace("src='icon/member_image_box/","src='$_zboard_url"."icon/member_image_box/",$tmp);

return $tmp;
}

// 문서에서 이미지태그 추출
function get_imgTag($tmp, $ismember='0', $num='1') {

$tmp=convt_imagebox($tmp, $ismember);

for($i=0; $i<=$num; $i++) {
for($j=$j; $j<=strlen($tmp); $j++){
if($flag==0 && $tmp[$j] == '<' && strtolower(substr($tmp,$j+1,3)) == 'img') $flag=1;
if($flag==1 && $tmp[$j] != '>') $prtstr[$i] .= $tmp[$j];
if($flag==1 && $tmp[$j] == '>') {$prtstr[$i] .= $tmp[$j]; $j++; break;}
}
$flag=0;
}
if($prtstr) return $prtstr;
}

// 문자열에서 url경로 추출
function get_urlPath($str) {
if(eregi("\.jpg",$str))  $_file_type = ".jpg";
if(eregi("\.jpeg",$str)) $_file_type = ".jpeg";
if(eregi("\.gif",$str))  $_file_type = ".gif";
if(eregi("\.png",$str))  $_file_type = ".png";
if(eregi("\.bmp",$str))  $_file_type = ".bmp";
if(eregi("\.wmf",$str))  $_file_type = ".wmf";

$old_autoResize_text  = " name=zb_target_resize style=\"cursor:hand\" onclick=window.open(this.src)";
$str=str_replace($old_autoResize_text,'',$str);

if(!eregi('\?',$str)) $str=str_replace(" ","_DQ_TEMP_STRING_",substr($str,0,strpos(strtolower($str),$_file_type)+(strlen($_file_type)+1)));
$link_pattern = ";((http|https|ftp)://)?[/.?\xA1-\xFEa-zA-Z0-9:_\-]+[.][/?\xA1-\xFEa-zA-Z0-9,:\;&#=_~%()\[\]?\/.,+\*\-]+;i";
preg_match($link_pattern,$str,$ret);

//리눅스 시스템이라면 %20 문자를 공백으로 바꾼다.
$server_os  = get_serverOS();
if(eregi("linux", $server_os)) $ret[0] = str_replace("_DQ_TEMP_STRING_"," ",$ret[0]);
else $ret[0] = str_replace("_DQ_TEMP_STRING_","%20",$ret[0]);

return $ret[0];
}

// url을 절대경로로 반환
function get_url2realpath($str) {
$_http_host_url = $_SERVER[HTTP_HOST];

if(substr($_http_host_url,0,4)!="www.") {
$_http_host1 = 'http://'.$_http_host_url;
$_http_host2 = 'http://www.'.$_http_host_url;
} else {
$_http_host1 = 'http://'.substr($_http_host_url,4,strlen($_http_host_url));
$_http_host2 = 'http://'.$_http_host_url;
}

$_getImageURL = str_replace($_http_host1,'',str_replace('www.','',$str));
if(substr($_getImageURL,0,1)=='/') $str_chkImage = get_indexDir().$_getImageURL; else $str_chkImage = $_getImageURL;

return $str_chkImage;
}

// url엔코딩
function dq_urlencode($url_path) {
global $dqEngine;

if(!$dqEngine['using_urlenc']) return $url_path;
$url_temp=parse_url(trim($url_path));
if($url_temp[query]) $url_q="?".$url_temp[query];
$url=str_replace($url_q,"",trim($url_path));
$url_temp=str_replace("%3A",":",str_replace("%2F","/",rawurlencode($url)));
$url=$url_temp.$url_q;

return $url;
}

// 서버 OS 알아내기
function get_serverOS () {
if(function_exists("posix_uname")) {
$server = posix_uname();
return $server[sysname]." ".$server[release];
}
ob_start();
phpinfo(1);
$server_os=ob_get_contents();
ob_end_clean();
$server_os=strip_tags(stristr($server_os, 'System'));
$server_os=explode("\n",$server_os);
return substr($server_os[0],6,strlen($server_os[0]));
}

// PHPThumb에서 가져온 소스들 (약간 수정)
function phpinfo_array() {
static $phpinfo_array = array();
if (empty($phpinfo_array)) {
ob_start();
phpinfo();
$phpinfo = ob_get_contents();
ob_end_clean();
$phpinfo_array = explode("\n", $phpinfo);
}
return $phpinfo_array;
}

function get_exif_info() {
static $exif_info = array();
if (empty($exif_info)) {
$exif_info = array(
'EXIF Support'          => '',
'EXIF Version'          => '',
'Supported EXIF Version' => '',
'Supported filetypes'    => ''
);
$phpinfo_array = phpinfo_array();
foreach ($phpinfo_array as $line) {
$line = trim(strip_tags($line));
foreach ($exif_info as $key => $value) {
if (strpos($line, $key) === 0) {
$newvalue = trim(str_replace($key, '', $line));
$exif_info[$key] = $newvalue;
}
}
}
}
return $exif_info;
}

function get_GDVersion($fullstring=0) {
static $cache_gd_version = array();
if (empty($cache_gd_version)) {
$gd_info = get_GDInfo();
if (substr($gd_info['GD Version'], 0, strlen('bundled (')) == 'bundled (') {
$cache_gd_version[1] = $gd_info['GD Version'];
$cache_gd_version[0] = (float) substr($gd_info['GD Version'], strlen('bundled ('), 3);
} else {
$cache_gd_version[1] = $gd_info['GD Version'];
$cache_gd_version[0] = (float) substr($gd_info['GD Version'], 0, 3);
}
}
return $cache_gd_version[intval($fullstring)];
}

function get_GDInfo() {
if (function_exists('gd_info')) {
return gd_info();
}

static $gd_info = array();
if (empty($gd_info)) {
$gd_info = array(
'GD Version'        => '',
'FreeType Support'  => false,
'FreeType Linkage'  => '',
'T1Lib Support'      => false,
'GIF Read Support'  => false,
'GIF Create Support' => false,
'JPG Support'        => false,
'PNG Support'        => false,
'WBMP Support'      => false,
'XBM Support'        => false
);

$phpinfo_array = phpinfo_array();
foreach ($phpinfo_array as $line) {
$line = trim(strip_tags($line));
foreach ($gd_info as $key => $value) {
if (strpos($line, $key) === 0) {
$newvalue = trim(str_replace($key, '', $line));
$gd_info[$key] = $newvalue;
}
}
}

if (empty($gd_info['GD Version'])) {
if (function_exists('ImageTypes')) {
$imagetypes = ImageTypes();
if ($imagetypes & IMG_PNG) {
$gd_info['PNG Support'] = true;
}
if ($imagetypes & IMG_GIF) {
$gd_info['GIF Create Support'] = true;
}
if ($imagetypes & IMG_JPG) {
$gd_info['JPG Support'] = true;
}
if ($imagetypes & IMG_WBMP) {
$gd_info['WBMP Support'] = true;
}
}
if (function_exists('ImageCreateFromGIF')) {
if ($tempfilename = tempnam(null, '_thumb_')) {
if ($fp_tempfile = @fopen($tempfilename, 'wb')) {
fwrite($fp_tempfile, base64_decode('R0lGODlhAQABAIAAAH//AP///ywAAAAAAQABAAACAUQAOw=='));
fclose($fp_tempfile);
$gd_info['GIF Read Support'] = (bool) @ImageCreateFromGIF($tempfilename);
}
unlink($tempfilename);
}
}
if (function_exists('ImageCreateTrueColor') && @ImageCreateTrueColor(1, 1)) {
$gd_info['GD Version'] = '2.0.1 or higher (assumed)';
} elseif (function_exists('ImageCreate') && @ImageCreate(1, 1)) {
$gd_info['GD Version'] = '1.6.0 or higher (assumed)';
}
}
}
return $gd_info;
}

// USM 필터(PHP 4.3.2 에서는 동작하지 않는다.)
function UnsharpMask($img, $amount='60', $radius='0.5', $threshold='1') {

////////////////////////////////////////////////////////////////////////////////////////////////
////
////                  p h p U n s h a r p M a s k
////
//// Unsharp mask algorithm by Torstein H?si 2003.
////         thoensi_at_netcom_dot_no.
////           Please leave this notice.
////
///////////////////////////////////////////////////////////////////////////////////////////////


// $img is an image that is already created within php using
// imgcreatetruecolor. No url! $img must be a truecolor image.

// Attempt to calibrate the parameters to Photoshop:

if(eregi('4.3.2',phpversion())) return $img;

$amount = min($amount, 500);
$amount = $amount * 0.016;

$radius = min($radius, 50);
$radius = $radius * 2;

$threshold = min($threshold, 255);

$radius = abs(round($radius)); // Only integers make sense.
if ($radius == 0) {
return $img;
//ImageDestroy($img);
//break;
}
$w = ImageSX($img);
$h = ImageSY($img);
$imgCanvas  = ImageCreateTrueColor($w, $h);
$imgCanvas2 = ImageCreateTrueColor($w, $h);
$imgBlur    = ImageCreateTrueColor($w, $h);
$imgBlur2  = ImageCreateTrueColor($w, $h);
ImageCopy($imgCanvas,  $img, 0, 0, 0, 0, $w, $h);
ImageCopy($imgCanvas2, $img, 0, 0, 0, 0, $w, $h);


// Gaussian blur matrix:
//
// 1 2 1
// 2 4 2
// 1 2 1
//
//////////////////////////////////////////////////

// Move copies of the image around one pixel at the time and merge them with weight
// according to the matrix. The same matrix is simply repeated for higher radii.
for ($i = 0; $i < $radius; $i++) {
ImageCopy    ($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1);            // up left
ImageCopyMerge($imgBlur, $imgCanvas, 1, 1, 0, 0, $w,    $h,    50);        // down right
ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h,    33.33333);  // down left
ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 1, $w,    $h - 1, 25);        // up right
ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h,    33.33333);  // left
ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 0, $w,    $h,    25);        // right
ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 1, $w,    $h - 1, 20 );      // up
ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 0, 0, $w,    $h,    16.666667); // down
ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 0, $w,    $h,    50);        // center
ImageCopy    ($imgCanvas, $imgBlur, 0, 0, 0, 0, $w,    $h);

// During the loop above the blurred copy darkens, possibly due to a roundoff
// error. Therefore the sharp picture has to go through the same loop to
// produce a similar image for comparison. This is not a good thing, as processing
// time increases heavily.
ImageCopy    ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 20 );
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 16.666667);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50);
ImageCopy    ($imgCanvas2, $imgBlur2, 0, 0, 0, 0, $w, $h);
}

// Calculate the difference between the blurred pixels and the original
// and set the pixels
for ($x = 0; $x < $w; $x++) { // each row
for ($y = 0; $y < $h; $y++) { // each pixel

$rgbOrig = ImageColorAt($imgCanvas2, $x, $y);
$rOrig = (($rgbOrig >> 16) & 0xFF);
$gOrig = (($rgbOrig >>  8) & 0xFF);
$bOrig =  ($rgbOrig        & 0xFF);

$rgbBlur = ImageColorAt($imgCanvas, $x, $y);
$rBlur = (($rgbBlur >> 16) & 0xFF);
$gBlur = (($rgbBlur >>  8) & 0xFF);
$bBlur =  ($rgbBlur        & 0xFF);

// When the masked pixels differ less from the original
// than the threshold specifies, they are set to their original value.
$rNew = (abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig;
$gNew = (abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig;
$bNew = (abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig;

$pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew);
ImageSetPixel($img, $x, $y, $pixCol);
}
}
ImageDestroy($imgCanvas);
ImageDestroy($imgCanvas2);
ImageDestroy($imgBlur);
ImageDestroy($imgBlur2);
return $img;
//ImageDestroy($img);
}

// 정확한 document_root 값 찾아내기(서버에 따라 엉뚱하게 리턴하는 경우가 있어서 정밀한 검사가 필요하다)
function get_indexDir() {
global $_SERVER;
$docroot = $_SERVER["DOCUMENT_ROOT"] ? $_SERVER["DOCUMENT_ROOT"] : '\$empty\$';
$scriptfile = $_SERVER["SCRIPT_FILENAME"] ? $_SERVER["SCRIPT_FILENAME"] : $_SERVER["PATH_TRANSLATED"];
$phpself = $_SERVER["PHP_SELF"];

if(!$scriptfile) die("<div style='background-color:yellow;color:black'><b>스크립트 파일에 대한 정보가 없습니다.</b> ::이 서버에서는 실행할수 없습니다. ::</div>");

if(!eregi($docroot,$scriptfile)) {
$os = get_serveros();
if(eregi("windows",$os)) $scriptfile = str_replace("\\","/",$scriptfile);
if (substr($phpself,0,2)=='/~') {
$pattern = ":/~+(/+):i";
$scriptfile = str_replace($pattern,"\\1",$scriptfile);
}

$tmp = str_replace($phpself,'',$scriptfile).'/';
} else $tmp = $docroot;
return $tmp;
}

?>
엔진과는 아무 상관없습니다.
문제는 썸네일 업데이트가 안되고 있는겁니다.
그말은 새로운 사진을 넣었을 때 과거 썸네일 삭제가 안되었다는 말

// 회원원본 이미지를 아래로 치환
$mPhoto_image_path = "{$g4['path']}/data/mPhoto_image/{mb_id}";

// 회원 썸네일 큰거, 작은거를 아래로 치환
$mPhoto_thumb_path = "{$g4['path']}/data/mPhoto_image/thumb/{mb_id}.s_thumb";
$mPhoto_thumb_path2 = "{$g4['path']}/data/mPhoto_image/thumb/{mb_id}.l_thumb";

//회원삭제되었으면  원본, 썸1, 2 삭제
if( file_exists($mPhoto_image_path) && $mPhoto_image_del ) {
@unlink($mPhoto_image_path);
@unlink($mPhoto_thumb_path);
@unlink($mPhoto_thumb_path2);
}

수정시 업데이트 되는 루틴이 없어서 그럽니다.
사진이 새로등록되면 과거 썸을 삭제하고 새로 만들기를 해야하는데
새로만들기 루틴에는 썸이 있냐 없냐? 없으면 만들고 있으면 있는걸 뿌려줘라!  여기까지 있는겁니다.

write.update 되는 쪽 파일 여시고 업데이트시 썸네일 삭제하게 넣어주셔야 합니다. 이게 정석입니다
빼와서 무조건 썸네일 삭제하고 다시 만들기를 하시거나요...

아래소스를 원소스 상단에 있는것과 바꾸세요.. else문 추가

if( file_exists($mPhoto_image_path) && $mPhoto_image_del ) {  // 회원 삭제면 원본,썸1,썸2삭제
@unlink($mPhoto_image_path);
@unlink($mPhoto_thumb_path);
@unlink($mPhoto_thumb_path2);
}else{
@unlink($mPhoto_thumb_path); // 있더라도 썸1, 썸2 삭제    새로만들꺼니까..
@unlink($mPhoto_thumb_path2);
}
전체 4 |RSS
그누4 질문답변 내용 검색
  • 개별 목록 구성 번호 제목 작성자 작성일 조회
  • 게시물이 없습니다.

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT