확장자 없는 이미지 썸네일 만들 방법이 없을까요? 정보
확장자 없는 이미지 썸네일 만들 방법이 없을까요?
본문
추천
0
0
댓글 7개

<?
for ($i=0; $i<count($list); $i++) {
//썸네일 생성
$thumfile = "";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
// 업로드된 파일이 이미지라면
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
break;
$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
} else { //editor로 삽입한 이미지
$edit_img = $list[$i]['wr_content'];
if (eregi("data/[^<>]*\.(gif|jp[e]?g|png|bmp)", $edit_img, $tmp)) { // data/editor------
$file = $g4[path].'/'.$tmp[0]; // 파일명
$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 = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
}
/*
$edit_img = $list[$i]['wr_content'];
if (eregi("data/[^<>]*\.(gif|jp[e]?g|png|bmp)", $edit_img, $tmp)) {
for ($k=0; $k<count($tmp); $k++)
echo $tmp[$k]."<br>".count($tmp);
}
exit;
*/
$subjectv = cut_str(strip_tags($list[$i][subject]), 50);
$contentv = cut_str(strip_tags($list[$i][wr_content]), 58);
if (file_exists($thumb))
$thumfile = "<img src='$thumb' alt='' />";
else
//이미지가 없으면
$thumfile="<img src='$latest_skin_path/img/noimg.gif' alt='' />";
//이미지가 아니네
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file))
{ $thumfile="<img src='$latest_skin_path/img/noimg.gif' alt='' />";}
?>
<div class="ps_album" style="opacity:0;"><?=$thumfile?><div class="ps_desc"><h2><?=$subjectv?></h2><span><?=$contentv?></span></div></div>
<?}?>
for ($i=0; $i<count($list); $i++) {
//썸네일 생성
$thumfile = "";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
// 업로드된 파일이 이미지라면
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
break;
$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
} else { //editor로 삽입한 이미지
$edit_img = $list[$i]['wr_content'];
if (eregi("data/[^<>]*\.(gif|jp[e]?g|png|bmp)", $edit_img, $tmp)) { // data/editor------
$file = $g4[path].'/'.$tmp[0]; // 파일명
$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 = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
}
/*
$edit_img = $list[$i]['wr_content'];
if (eregi("data/[^<>]*\.(gif|jp[e]?g|png|bmp)", $edit_img, $tmp)) {
for ($k=0; $k<count($tmp); $k++)
echo $tmp[$k]."<br>".count($tmp);
}
exit;
*/
$subjectv = cut_str(strip_tags($list[$i][subject]), 50);
$contentv = cut_str(strip_tags($list[$i][wr_content]), 58);
if (file_exists($thumb))
$thumfile = "<img src='$thumb' alt='' />";
else
//이미지가 없으면
$thumfile="<img src='$latest_skin_path/img/noimg.gif' alt='' />";
//이미지가 아니네
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file))
{ $thumfile="<img src='$latest_skin_path/img/noimg.gif' alt='' />";}
?>
<div class="ps_album" style="opacity:0;"><?=$thumfile?><div class="ps_desc"><h2><?=$subjectv?></h2><span><?=$contentv?></span></div></div>
<?}?>

벌이뉨님 답변 주셔서 감사합니다.
근데 위 소스는 확장자가 없으면 썸네일이 생성안됩니다.
불당썸도 안되구요.
근데 위 소스는 확장자가 없으면 썸네일이 생성안됩니다.
불당썸도 안되구요.

아 저는 썸네일을 생성한 후 확장자가 없게 하려는지 알았어요 ㅜㅜ 죄송
확장자가 없이 어떻게 썸네일을 만듭니까??? 질문이 잘못된 겁니다. 이미지를 만들려면 jpeg나 gif나 tiff나 bmp와 같이 확장자로 정한 규격대로 이미지를 만들어 내는 겁니다. 썸네일은 단지 크기를 작게 조절하는 것일 뿐이구요. 처음부터 확장자 없는 이미지란 말 자체가 성립되지 않습니다.

그런가요?
그런데 본문의 링크를 확인은 하시고 댓글 다시는건가요?
그런데 본문의 링크를 확인은 하시고 댓글 다시는건가요?
이미지를 만들려면 당연히 확장자가 필요합니다. 다만 프로그램을 짤 때 확장자를 숨기도록 이름에서 없애는 것일 뿐이에요.
bek.me 에서 보여주는 건 원래는 jpg 를 아파치 rewrite기능을 이용해 감추었을 뿐입니다. 밑에서 실제 파일을 가져올 때는 끝에 .jpg를 붙인다고 설명까지 했쟌아요.
그리고 예제는 이미 확장자를 감춘 사이트의 그림을 가져와서 썸네일을 만드는 거고, 열공중님은 질문을 확장자 없이 섬네일을 만드는 걸 질문한 거고. 완전히 다른 질문을 하고 있는 겁니다.
bek.me 에서 보여주는 건 원래는 jpg 를 아파치 rewrite기능을 이용해 감추었을 뿐입니다. 밑에서 실제 파일을 가져올 때는 끝에 .jpg를 붙인다고 설명까지 했쟌아요.
그리고 예제는 이미 확장자를 감춘 사이트의 그림을 가져와서 썸네일을 만드는 거고, 열공중님은 질문을 확장자 없이 섬네일을 만드는 걸 질문한 거고. 완전히 다른 질문을 하고 있는 겁니다.

질문을 잘못 이해하신듯 하네요.
질문은 티스토리 이미지를 외부이미지 저장 소스로 복사 붙여넣기로 글쓰면요.
글쓴사이트에 이미지가 저장이됩니다.
티스토리는 확장자가 없는주소가 복사되어서 붙여넣기 하였으므로
글쓴사이트에 저장될때도 확장자가 없이 저장이됩니다.
글쓴사이트에 저장된 확장자없는 이미지를 썸네일 만드는걸 여쭌겁니다.
다른곳 확장자가 있는이미지는 저장될때 확장도 같이 저장이됩니다.
질문은 티스토리 이미지를 외부이미지 저장 소스로 복사 붙여넣기로 글쓰면요.
글쓴사이트에 이미지가 저장이됩니다.
티스토리는 확장자가 없는주소가 복사되어서 붙여넣기 하였으므로
글쓴사이트에 저장될때도 확장자가 없이 저장이됩니다.
글쓴사이트에 저장된 확장자없는 이미지를 썸네일 만드는걸 여쭌겁니다.
다른곳 확장자가 있는이미지는 저장될때 확장도 같이 저장이됩니다.