워터마크 > php

본문 바로가기
사이트 내 전체검색

php

워터마크

페이지 정보

작성자 서방님 댓글 0건 조회 108회 작성일 12-02-03 10:54

본문

$font_size = 12; // 글자 크기
$opacity = 20; // 투명도 높을수록 불투명
$font_path = "NanumGothic.ttf";  //폰트 NanumGothic,NanumGothicExtraBold,NanumPen
$string = "워터마크";  // 찍을 워터마크 글자
$string = iconv("EUC-KR","UTF-8","$string");

$image = $original;

$image_name = explode(".",$image);
$image_targ = $image_name[0]."_marked.jpg";  // 워터마크가 찍혀 저장될 이미지

$image_org = $image; // 원본 이미지를 다른 이름으로 저장
$image = imagecreatefromjpeg($image); // JPG 이미지를 읽고

$w = imagesx($image);
$h = imagesy($image); 

$text_color = imagecolorallocate($image,255,255,255); // 텍스트 컬러 지정

// 적당히 워터마크가 붙을 위치를 지정
$text_pos_x = $font_size;
$text_pos_y = $h - $font_size;

imagettftext($image, $font_size, 0, $text_pos_x, $text_pos_y, $text_color, $font_path, $string);  // 읽은 이미지에 워터마크를 찍고

$image_org = imagecreatefromjpeg($image_org); // 원본 이미지를 다시한번 읽고
 
imagecopymerge($image,$image_org,0,0,0,0,$w,$h,$opacity); // 원본과 워터마크를 찍은 이미지를 적당한 투명도로 겹치기

imagejpeg($image, $image_targ, 90); // 이미지 저장. 해상도는 90 정도
 
imagedestroy($image);
imagedestroy($image_org);

 

 

Capture_5.jpg

댓글목록

등록된 댓글이 없습니다.

Total 612건 35 페이지
게시물 검색

회원로그인

접속자집계

오늘
285
어제
225
최대
1,347
전체
155,044
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.