영카트프로그램에 워터마크 삽입 안되나요? 정보
영카트프로그램에 워터마크 삽입 안되나요?
본문
상품관리에서 상품을 등록할때..
상품이미지를 넣을때 일일이 포토샵에서 이미지에 로고를 삽입하고 있습니다.
팁란에 보니
http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=15645
게시판 이미지 워터마크 찍는 팁이 있네요
-------------------소스-----------------------
<?
// 자신만의 코드를 넣어주세요.
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
$sql2=" select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no asc";
$results2 = sql_query($sql2);
for ($d=0; $row2=sql_fetch_array($results2); $d++) {
if ($_FILES[bf_file][name][$d])
{
$file = $data_path .'/'. $row2[bf_file];
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file))
{
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
break;
$rate = $board[bo_image_width] / $size[0]; // 리사이즈를 원치않으면 여기서부터~~~
$height = (int)($size[1] * $rate);
if ($size[0] > $board[bo_image_width]){
@unlink($data_path.'/'.$row2[bf_file]);
$dst = imagecreatetruecolor($board[bo_image_width], $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $board[bo_image_width], $height, $size[0], $size[1]);
imagejpeg($dst, $data_path.'/'.$row2[bf_file], $board[bo_2]); //혹 업로드 이미지 깨지면 여긴 주석처리하시고 바로 아래 껄 이용하세요..
// imagepng($dst, $data_path.'/'.$row2[bf_file], $board[bo_2]); //주석 해제
chmod($data_path.'/'.$row2[bf_file], 0606);
$temp = @getimagesize(addslashes($file));
} // 리사이즈를 원치않으면 여기까지 삭제 & 주석처리하면 됨.
$wmFile = $g4[path]."/img/logo_mark.gif"; // 워터마크 이미지 주소
$wmImg = imageCreateFromGIF($wmFile);
$size = getimagesize($file);
if ($size[2] == 1)
$jpegImg = imagecreatefromgif($file);
else if ($size[2] == 2)
$jpegImg = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$jpegImg = imagecreatefrompng($file);
else
break;
$wmX=imageSX($jpegImg) - imageSX($wmImg);
$wmY=imageSY($jpegImg) - imageSY($wmImg);
imageCopyMerge($jpegImg, $wmImg, $wmX, $wmY, 0, 0, imageSX($wmImg), imageSY($wmImg), 90);
ImageJPEG($jpegImg, $file, 90);
}
}
}
?>
-----------------------------끝----------------------------
영카트에 적용을 하려해도 안되네요..
좀 도와주세요..
상품이미지를 넣을때 일일이 포토샵에서 이미지에 로고를 삽입하고 있습니다.
팁란에 보니
http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=15645
게시판 이미지 워터마크 찍는 팁이 있네요
-------------------소스-----------------------
<?
// 자신만의 코드를 넣어주세요.
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
$sql2=" select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no asc";
$results2 = sql_query($sql2);
for ($d=0; $row2=sql_fetch_array($results2); $d++) {
if ($_FILES[bf_file][name][$d])
{
$file = $data_path .'/'. $row2[bf_file];
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file))
{
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
break;
$rate = $board[bo_image_width] / $size[0]; // 리사이즈를 원치않으면 여기서부터~~~
$height = (int)($size[1] * $rate);
if ($size[0] > $board[bo_image_width]){
@unlink($data_path.'/'.$row2[bf_file]);
$dst = imagecreatetruecolor($board[bo_image_width], $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $board[bo_image_width], $height, $size[0], $size[1]);
imagejpeg($dst, $data_path.'/'.$row2[bf_file], $board[bo_2]); //혹 업로드 이미지 깨지면 여긴 주석처리하시고 바로 아래 껄 이용하세요..
// imagepng($dst, $data_path.'/'.$row2[bf_file], $board[bo_2]); //주석 해제
chmod($data_path.'/'.$row2[bf_file], 0606);
$temp = @getimagesize(addslashes($file));
} // 리사이즈를 원치않으면 여기까지 삭제 & 주석처리하면 됨.
$wmFile = $g4[path]."/img/logo_mark.gif"; // 워터마크 이미지 주소
$wmImg = imageCreateFromGIF($wmFile);
$size = getimagesize($file);
if ($size[2] == 1)
$jpegImg = imagecreatefromgif($file);
else if ($size[2] == 2)
$jpegImg = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$jpegImg = imagecreatefrompng($file);
else
break;
$wmX=imageSX($jpegImg) - imageSX($wmImg);
$wmY=imageSY($jpegImg) - imageSY($wmImg);
imageCopyMerge($jpegImg, $wmImg, $wmX, $wmY, 0, 0, imageSX($wmImg), imageSY($wmImg), 90);
ImageJPEG($jpegImg, $file, 90);
}
}
}
?>
-----------------------------끝----------------------------
영카트에 적용을 하려해도 안되네요..
좀 도와주세요..
댓글 전체
워터마크의 경우 파일업로드 부분에서 생성을 해줘야 합니다.
초보시라면 어려우시고여 어느정도 능숙하신분이라면 팁을 보시고 차근차근 따라해 보시면 될듯합니다.
초보시라면 어려우시고여 어느정도 능숙하신분이라면 팁을 보시고 차근차근 따라해 보시면 될듯합니다.
영카트 소스 입니다.
@mkdir("$g4[path]/data/item", 0707);
@chmod("$g4[path]/data/item", 0707);
if ($it_himg_del) @unlink("$g4[path]/data/item/{$it_id}_h");
if ($it_timg_del) @unlink("$g4[path]/data/item/{$it_id}_t");
if ($it_simg_del) @unlink("$g4[path]/data/item/{$it_id}_s");
if ($it_mimg_del) @unlink("$g4[path]/data/item/{$it_id}_m");
if ($it_limg1_del) @unlink("$g4[path]/data/item/{$it_id}_l1");
if ($it_limg2_del) @unlink("$g4[path]/data/item/{$it_id}_l2");
if ($it_limg3_del) @unlink("$g4[path]/data/item/{$it_id}_l3");
if ($it_limg4_del) @unlink("$g4[path]/data/item/{$it_id}_l4");
if ($it_limg5_del) @unlink("$g4[path]/data/item/{$it_id}_l5");
// 이미지(대)만 업로드하고 자동생성 체크일 경우 이미지(중,소) 자동생성
if ($createimage && $_FILES[it_limg1][name])
{
upload_file($_FILES[it_limg1][tmp_name], $it_id."_l1", "$g4[path]/data/item");
$image = "$g4[path]/data/item/$it_id"."_l1";
$size = getimagesize($image);
$src = @imagecreatefromjpeg($image);
if (!$src)
{
echo "<script>alert('이미지(대)가 JPG 파일이 아닙니다.');</script>";
}
else
{
// gd 버전에 따라
if (function_exists("imagecopyresampled")) {
// 이미지(소) 생성
$dst = imagecreatetruecolor($default[de_simg_width], $default[de_simg_height]);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $default[de_simg_width], $default[de_simg_height], $size[0], $size[1]);
} else {
// 이미지(소) 생성
$dst = imagecreate($default[de_simg_width], $default[de_simg_height]);
imagecopyresized($dst, $src, 0, 0, 0, 0, $default[de_simg_width], $default[de_simg_height], $size[0], $size[1]);
}
imagejpeg($dst, "$g4[path]/data/item/$it_id"."_s", 90);
if (function_exists("imagecopyresampled")) {
// 이미지(중) 생성
$dst = imagecreatetruecolor($default[de_mimg_width], $default[de_mimg_height]);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $default[de_mimg_width], $default[de_mimg_height], $size[0], $size[1]);
} else {
// 이미지(중) 생성
$dst = imagecreate($default[de_mimg_width], $default[de_mimg_height]);
imagecopyresized($dst, $src, 0, 0, 0, 0, $default[de_mimg_width], $default[de_mimg_height], $size[0], $size[1]);
}
@imagejpeg($dst, "$g4[path]/data/item/$it_id"."_m", 90);
}
}
@mkdir("$g4[path]/data/item", 0707);
@chmod("$g4[path]/data/item", 0707);
if ($it_himg_del) @unlink("$g4[path]/data/item/{$it_id}_h");
if ($it_timg_del) @unlink("$g4[path]/data/item/{$it_id}_t");
if ($it_simg_del) @unlink("$g4[path]/data/item/{$it_id}_s");
if ($it_mimg_del) @unlink("$g4[path]/data/item/{$it_id}_m");
if ($it_limg1_del) @unlink("$g4[path]/data/item/{$it_id}_l1");
if ($it_limg2_del) @unlink("$g4[path]/data/item/{$it_id}_l2");
if ($it_limg3_del) @unlink("$g4[path]/data/item/{$it_id}_l3");
if ($it_limg4_del) @unlink("$g4[path]/data/item/{$it_id}_l4");
if ($it_limg5_del) @unlink("$g4[path]/data/item/{$it_id}_l5");
// 이미지(대)만 업로드하고 자동생성 체크일 경우 이미지(중,소) 자동생성
if ($createimage && $_FILES[it_limg1][name])
{
upload_file($_FILES[it_limg1][tmp_name], $it_id."_l1", "$g4[path]/data/item");
$image = "$g4[path]/data/item/$it_id"."_l1";
$size = getimagesize($image);
$src = @imagecreatefromjpeg($image);
if (!$src)
{
echo "<script>alert('이미지(대)가 JPG 파일이 아닙니다.');</script>";
}
else
{
// gd 버전에 따라
if (function_exists("imagecopyresampled")) {
// 이미지(소) 생성
$dst = imagecreatetruecolor($default[de_simg_width], $default[de_simg_height]);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $default[de_simg_width], $default[de_simg_height], $size[0], $size[1]);
} else {
// 이미지(소) 생성
$dst = imagecreate($default[de_simg_width], $default[de_simg_height]);
imagecopyresized($dst, $src, 0, 0, 0, 0, $default[de_simg_width], $default[de_simg_height], $size[0], $size[1]);
}
imagejpeg($dst, "$g4[path]/data/item/$it_id"."_s", 90);
if (function_exists("imagecopyresampled")) {
// 이미지(중) 생성
$dst = imagecreatetruecolor($default[de_mimg_width], $default[de_mimg_height]);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $default[de_mimg_width], $default[de_mimg_height], $size[0], $size[1]);
} else {
// 이미지(중) 생성
$dst = imagecreate($default[de_mimg_width], $default[de_mimg_height]);
imagecopyresized($dst, $src, 0, 0, 0, 0, $default[de_mimg_width], $default[de_mimg_height], $size[0], $size[1]);
}
@imagejpeg($dst, "$g4[path]/data/item/$it_id"."_m", 90);
}
}