첨부파일 워터마크 넣기 > 그누보드5 팁자료실

그누보드5 팁자료실

첨부파일 워터마크 넣기 정보

첨부파일 워터마크 넣기

본문

시간이 많이 없어서 영카트는 아직 확인하지 못했군요..
http://sir.co.kr/bbs/board.php?bo_table=g5_tip&wr_id=2297
에서 image_proc.function.php 소스 복사하시면 됩니다.

이건 첨부파일 용이라 에디터는 적용안됩니다!!




//워터마크 체크할 파일 인클루드
include_once(G5_LIB_PATH.'/image_proc.function.php');

$sql_data = "select * from  g5_board_file where bo_table = '$bo_table' and wr_id = '$wr_id' "; 
$res_data = mysql_query($sql_data);
while ($row_data = mysql_fetch_array($res_data)) { 

$exp = $row_data[bf_file];//원본파일
$exp_img = explode(".",$exp);
//확장자가 이미지 일때만
if ($exp_img[1] == "jpg" or $exp_img[1] == "png" or $exp_img[1] == "gif" or $exp_img[1] == "jpeg" or $exp_img[1] == "JPG" or $exp_img[1] == "PNG" or $exp_img[1] == "GIF" or $exp_img[1] == "JPEG") {

$path_file = G5_PATH.'/data/file/'.$bo_table."/".$row_data[bf_file];
$path_mark_file = G5_PATH.'/img/wtm.gif';//워터마크에 사용할 파일
$path_save_top_right_file =  G5_PATH.'/data/file/'.$bo_table."/".$row_data[bf_file]; //워터마크 처리한 것을 원본에 덮어씌움

//원본의 이미지 리소스를 받아온다.
list($src, $src_w, $src_h) = get_image_resource_from_file ($path_file);
if (empty($src)) die($GLOBALS['errormsg'] . "<br />\n");

//워터마크에 사용될 이미지 리소스를 받아온다.
list($mark, $mark_w, $mark_h) = get_image_resource_from_file ($path_mark_file);
if (empty($mark)) die($GLOBALS['errormsg'] . "<br />\n");

//원본을 5 분의 1로 축소한 너비와 높이를 구한다.
$src_w_small = $src_w; //리사이징 제거함
$src_h_small = get_size_by_rule($src_w, $src_h, $src_w_small);

//원본의 상단 오른쪽을 기준으로 선명도 100으로 워터마크 처리
if ($src_w > 200) { //width가 200 이하인 이미지는 워터마크 처리안함
$src2 = get_image_resize($src, $src_w, $src_h, $src_w_small, $src_h_small);
if (empty($src2)) die($GLOBALS['errormsg'] . "<br />\n");


$src2_x = $src_w_small - $mark_w;
$src2_y = 0;

//padding 을 10px 씩 줘야 하므로 x좌표는 왼쪽으로 10 이동 y좌표는 아래로 10 이동
$src2_x -= 10;
$src2_y += 10;

//워터마크는 투명도 50으로 설정
$result_watermark = imagecopymerge($src2, $mark, $src2_x, $src2_y, 0, 0, $mark_w, $mark_h, 50);
if ($result_watermark === false) die("워터마크 처리에 실패하였습니다.<br />\n");

$result_save = save_image_from_resource ($src2, $path_save_top_right_file, 100, 2);//저장
if ($result_save === false) die($GLOBALS['errormsg'] . "<br />\n");

@imagedestroy($src2);
				}

			} // if
		}
추천
3

댓글 9개

전체 2,431 |RSS
그누보드5 팁자료실 내용 검색

회원로그인

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