회원사진 업로드에서 질문입니다... 정보
회원사진 업로드에서 질문입니다...
본문
유아원님의 팁과
유디님의 팁을 합쳐서
회원사진 업로드를 성공적으로 달았습니다만...
정~~~~~~~~~~~~~~~~~~말 멋진 팁이긴 한데 ㅡ_ㅜ...
유디님의 팁은 jpg 만 gd 변환시켜주는것 같더라고요...;;
png 나 gif 파일도 올리면 jpg로 변환시켜서 올려주는... 그런방식은 안될까요???
gd에 대해선 전혀 몰라서 그런지... 제멋대로 대충 확장자만 수정한걸로는 안되는군요 ㅡ_ㅜ;;
고수분들 부디 답변을~~;;
댓글 전체
전 게시판 내용보기에서 사용되는 코드로 사용합니다.
profile.skin.php
<img src='{$photo_file}' border='0' name='target_resize_image[]' align=absmiddle>
<script language="JavaScript">
// HTML 로 넘어온 <img ... > 태그의 폭이 테이블폭보다 크다면 테이블폭을 적용한다.
function resize_image()
{
var target = document.getElementsByName('target_resize_image[]');
var image_width = parseInt('200');
var image_height = 0;
for(i=0; i<target.length; i++) {
// 원래 사이즈를 저장해 놓는다
target[i].tmp_width = target[i].width;
target[i].tmp_height = target[i].height;
// 이미지 폭이 테이블 폭보다 크다면 테이블폭에 맞춘다
if(target[i].width > image_width) {
image_height = parseFloat(target[i].width / target[i].height)
target[i].width = image_width;
target[i].height = parseInt(image_width / image_height);
}
}
}
window.onload = resize_image;
</script>
profile.skin.php
<img src='{$photo_file}' border='0' name='target_resize_image[]' align=absmiddle>
<script language="JavaScript">
// HTML 로 넘어온 <img ... > 태그의 폭이 테이블폭보다 크다면 테이블폭을 적용한다.
function resize_image()
{
var target = document.getElementsByName('target_resize_image[]');
var image_width = parseInt('200');
var image_height = 0;
for(i=0; i<target.length; i++) {
// 원래 사이즈를 저장해 놓는다
target[i].tmp_width = target[i].width;
target[i].tmp_height = target[i].height;
// 이미지 폭이 테이블 폭보다 크다면 테이블폭에 맞춘다
if(target[i].width > image_width) {
image_height = parseFloat(target[i].width / target[i].height)
target[i].width = image_width;
target[i].height = parseInt(image_width / image_height);
}
}
}
window.onload = resize_image;
</script>
킁;; 그래도...;; 뭐랄까 gd를 이용하는게 좀더 이쁘게 정리되지 않나요 ㅜ_ㅜ;;
800x500 짜리 이미지라면 너무 커서 불러오는데 시간이 걸리는데다가 불러오고나면 각진 이미지...
gd로 gif 나 png 처리하는 방법은 없는건가요?
800x500 짜리 이미지라면 너무 커서 불러오는데 시간이 걸리는데다가 불러오고나면 각진 이미지...
gd로 gif 나 png 처리하는 방법은 없는건가요?
할 수 있습니다!
썸네일 생성코드를 수정하여 같다 붙이세요. ㅡ.ㅡa
썸네일 생성코드를 수정하여 같다 붙이세요. ㅡ.ㅡa
음;; 단순한 수정으론 안되는거죠?
<?
//썸네일 코드 시작
$data_path = $g4['path'] . "/data/member/{$mb_dir}";//라이브러리 파일 참조
$thumb_path = $data_path . '/thumb';
$view_w = 100; //썸네일 가로사이즈
$view_h = 75; //썸네일 세로사이즈
$sch_q = 100; //썸네일 퀼리티
if (!is_dir($thumb_path)) {
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
}
$filename = "{$mb[mb_id]}.jpg"; //파일명
$thumb = $thumb_path.'/'.$filename; //썸네일
if (!file_exists($thumb))
{
$file = $data_path.'/'.$filename; //원본
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($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
continue;
$rate = $view_w / $size[0];
$height = (int)($size[1] * $rate);
if ($height < $view_h)
$dst = imagecreatetruecolor($view_w, $height);
else
$dst = imagecreatetruecolor($view_w, $view_h);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $view_w, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$filename, $sch_q);
chmod($thumb_path.'/'.$filename, 0707);
}
}
echo "<img src=";
echo $thumb;
echo ">";
?>
//썸네일 코드 시작
$data_path = $g4['path'] . "/data/member/{$mb_dir}";//라이브러리 파일 참조
$thumb_path = $data_path . '/thumb';
$view_w = 100; //썸네일 가로사이즈
$view_h = 75; //썸네일 세로사이즈
$sch_q = 100; //썸네일 퀼리티
if (!is_dir($thumb_path)) {
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
}
$filename = "{$mb[mb_id]}.jpg"; //파일명
$thumb = $thumb_path.'/'.$filename; //썸네일
if (!file_exists($thumb))
{
$file = $data_path.'/'.$filename; //원본
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($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
continue;
$rate = $view_w / $size[0];
$height = (int)($size[1] * $rate);
if ($height < $view_h)
$dst = imagecreatetruecolor($view_w, $height);
else
$dst = imagecreatetruecolor($view_w, $view_h);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $view_w, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$filename, $sch_q);
chmod($thumb_path.'/'.$filename, 0707);
}
}
echo "<img src=";
echo $thumb;
echo ">";
?>
답변감사합니다~ ㅡ_ㅜ...
근데 어떻게 하는지는 전혀 모르겠습니다 Orz.... ←바보
근데 어떻게 하는지는 전혀 모르겠습니다 Orz.... ←바보
그대로 같다붙이면 됩니다. ㅡ.ㅡ
아아~~ 일반 페이지에서 처리하는건가 보군요 =ㅅ=;;;
저는 업로드시에 처리하는건줄 알구 ㅡ_ㅡ;;;
유아원님 감사합니다~~
저는 업로드시에 처리하는건줄 알구 ㅡ_ㅡ;;;
유아원님 감사합니다~~