이미지에 워터마크 처리하기
<?php
//이미지 처리 함수 인클루드
include_once 'lib/image_proc.function.php';
$path_file = 'sample_image/test.jpg';//원본파일
$path_mark_file ='sample_image/php.png';//워터마크에 사용할 파일
$path_save_file = 'sample_image/watermak.jpg';//워터마크 처리한 것을 저장할 파일
//원본의 이미지 리소스를 받아온다.
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");
//원본의 왼쪽 꼭지점을 기준점으로 선명도 60으로 워터마크 처리
$result_watermark = imagecopymerge($src, $mark, 0, 0, 0, 0, $mark_w, $mark_h, 60);
if ($result_watermark === false) die("워터마크 처리에 실패하였습니다.<br />\n");
$result_save = save_image_from_resource ($src, $path_save_file);//저장
if ($result_save === false) die($GLOBALS['errormsg'] . "<br />\n");
@imagedestroy($mark);
@imagedestroy($src);
//성공하였다면 이미지 출력
?>
원본 이미지 <br />
<img src='<?=$path_file?>'> <br />
워터마크에 사용할 이미지 <br />
<img src='<?=$path_mark_file?>'> <br />
워터마크 처리한 이미지 <br />
<img src='<?=$path_save_file?>'> <br />
//이미지 처리 함수 인클루드
include_once 'lib/image_proc.function.php';
$path_file = 'sample_image/test.jpg';//원본파일
$path_mark_file ='sample_image/php.png';//워터마크에 사용할 파일
$path_save_file = 'sample_image/watermak.jpg';//워터마크 처리한 것을 저장할 파일
//원본의 이미지 리소스를 받아온다.
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");
//원본의 왼쪽 꼭지점을 기준점으로 선명도 60으로 워터마크 처리
$result_watermark = imagecopymerge($src, $mark, 0, 0, 0, 0, $mark_w, $mark_h, 60);
if ($result_watermark === false) die("워터마크 처리에 실패하였습니다.<br />\n");
$result_save = save_image_from_resource ($src, $path_save_file);//저장
if ($result_save === false) die($GLOBALS['errormsg'] . "<br />\n");
@imagedestroy($mark);
@imagedestroy($src);
//성공하였다면 이미지 출력
?>
원본 이미지 <br />
<img src='<?=$path_file?>'> <br />
워터마크에 사용할 이미지 <br />
<img src='<?=$path_mark_file?>'> <br />
워터마크 처리한 이미지 <br />
<img src='<?=$path_save_file?>'> <br />
참고 : http://kr2.php.net/manual/kr/function.ceil.php
댓글 2개
takumi22
12년 전
유창화님 강의네요 ~~
12년 전
감사합니다
게시글 목록
| 번호 | 제목 |
|---|---|
| 20014 | |
| 10421 |
jQuery
jQuery Quick Api Reference
5
|
| 10417 | |
| 20006 |
CSS
그라디언트 에디터
7
|
| 20003 | |
| 10410 | |
| 10407 | |
| 10392 | |
| 10389 | |
| 10380 |
Mobile
디바이스별 viewport 설정. (수정본)
8
|
| 10378 | |
| 17596 | |
| 10371 | |
| 19995 | |
| 10369 | |
| 10366 | |
| 10364 |
jQuery
[펌] jQuery select box
1
|
| 10363 |
기타
구글 확장프로그램 추천
|
| 10361 |
정규표현식
캡쳐 그룹과 비캡쳐 그룹
1
|
| 10357 |
웹서버
php 업로드 용량 늘리기
3
|
| 10352 | |
| 19990 | |
| 10349 | |
| 10343 |
Mobile
디바이스별 viewport 설정.
5
|
| 10340 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기