어디서 주워온 함수인데요...
적용시켰는데 잘 되서 쓸려구 하는데 페이지 불러올대마다 재 생성 하는것같습니다.
좀 도와주세요;;
////////////////////////////////////
<?php
class thumbnails {
function ResizeImage($image, $newimage, $newwidth=0, $newheight=0) {
if (!function_exists('ImageTypes'))
return false;
list($width,$height,$type) = GetImageSize($image);
if ($im = self::ReadImageFromFile($image, $type)) {
if ($newwidth==0)
$newwidth = ($newheight / $height) * $width;
else if ($newheight==0)
$newheight = ($newwidth / $width) * $height;
elseif ($newheight && ($width < $height))
$newwidth = ($newheight / $height) * $width;
else
$newheight = ($newwidth / $width) * $height;
if (function_exists('ImageCreateTrueColor'))
$im2 = ImageCreateTrueColor($newwidth,$newheight);
else
$im2 = ImageCreate($newwidth,$newheight);
if (function_exists('imagealphablending'))
imagealphablending($im2, false);
if (function_exists('imagesavealpha'))
imagesavealpha ($im2 , true);
if (function_exists('ImageCopyResampled'))
ImageCopyResampled($im2,$im,0,0,0,0,$newwidth,$newheight,$width,$height);
else
ImageCopyResized($im2,$im,0,0,0,0,$newwidth,$newheight,$width,$height);
if (self::WriteImageToFile($im2, $newimage, $type))
return true;
}
return false;
}
private function ReadImageFromFile($filename, $type) {
$imagetypes = ImageTypes();
switch ($type) {
case 1 :
if ($imagetypes & IMG_GIF)
return $im = ImageCreateFromGIF($filename);
break;
case 2 :
if ($imagetypes & IMG_JPEG)
return ImageCreateFromJPEG($filename);
break;
case 3 :
if ($imagetypes & IMG_PNG)
return ImageCreateFromPNG($filename);
break;
default:
return 0;
}
}
private function WriteImageToFile($im, $filename, $type) {
switch ($type) {
case 1 :
return ImageGIF($im, $filename);
case 2 :
return ImageJpeg($im, $filename, 85);
case 3 :
return ImagePNG($im, $filename);
default:
return false;
}
}
}
//thumbnails::ResizeImage("00_folder.jpg", "mini/test.jpg", 150)
?>
////////////////////
불러오는 리스트 페이지에
if ($row["image1"] != "") {
thumbnails::ResizeImage("uploads/images/$row[image1]", "uploads/images/mini/$row[image1]", 150);
print("<td width=10><IMG src=uploads/images/mini/$row[image1]></td>");
}
//////////////////////////////
이렇게 했습니다.
이거 적용하는데 일주일 걸렸습니다 ,, 제발 좀 도와주세요 ㅠㅠ
적용시켰는데 잘 되서 쓸려구 하는데 페이지 불러올대마다 재 생성 하는것같습니다.
좀 도와주세요;;
////////////////////////////////////
<?php
class thumbnails {
function ResizeImage($image, $newimage, $newwidth=0, $newheight=0) {
if (!function_exists('ImageTypes'))
return false;
list($width,$height,$type) = GetImageSize($image);
if ($im = self::ReadImageFromFile($image, $type)) {
if ($newwidth==0)
$newwidth = ($newheight / $height) * $width;
else if ($newheight==0)
$newheight = ($newwidth / $width) * $height;
elseif ($newheight && ($width < $height))
$newwidth = ($newheight / $height) * $width;
else
$newheight = ($newwidth / $width) * $height;
if (function_exists('ImageCreateTrueColor'))
$im2 = ImageCreateTrueColor($newwidth,$newheight);
else
$im2 = ImageCreate($newwidth,$newheight);
if (function_exists('imagealphablending'))
imagealphablending($im2, false);
if (function_exists('imagesavealpha'))
imagesavealpha ($im2 , true);
if (function_exists('ImageCopyResampled'))
ImageCopyResampled($im2,$im,0,0,0,0,$newwidth,$newheight,$width,$height);
else
ImageCopyResized($im2,$im,0,0,0,0,$newwidth,$newheight,$width,$height);
if (self::WriteImageToFile($im2, $newimage, $type))
return true;
}
return false;
}
private function ReadImageFromFile($filename, $type) {
$imagetypes = ImageTypes();
switch ($type) {
case 1 :
if ($imagetypes & IMG_GIF)
return $im = ImageCreateFromGIF($filename);
break;
case 2 :
if ($imagetypes & IMG_JPEG)
return ImageCreateFromJPEG($filename);
break;
case 3 :
if ($imagetypes & IMG_PNG)
return ImageCreateFromPNG($filename);
break;
default:
return 0;
}
}
private function WriteImageToFile($im, $filename, $type) {
switch ($type) {
case 1 :
return ImageGIF($im, $filename);
case 2 :
return ImageJpeg($im, $filename, 85);
case 3 :
return ImagePNG($im, $filename);
default:
return false;
}
}
}
//thumbnails::ResizeImage("00_folder.jpg", "mini/test.jpg", 150)
?>
////////////////////
불러오는 리스트 페이지에
if ($row["image1"] != "") {
thumbnails::ResizeImage("uploads/images/$row[image1]", "uploads/images/mini/$row[image1]", 150);
print("<td width=10><IMG src=uploads/images/mini/$row[image1]></td>");
}
//////////////////////////////
이렇게 했습니다.
이거 적용하는데 일주일 걸렸습니다 ,, 제발 좀 도와주세요 ㅠㅠ
댓글 3개
17년 전
출력부분에
$thumb = "uploads/images/mini/$row[image1]";
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
thumbnails::ResizeImage("uploads/images/$row[image1]", "uploads/images/mini/$row[image1]", 150);
}
else if (file_exists($thumb)) {
$img = "<img src='$thumb' height=54 border=0 style='border:1px solid #a1a1a1;margin-right:10px;'>";
}
else {
$img = "<img src='images/t.gif' border=0>";
}
print("<td width=10>$img</td>");
눈치껏 해봤는데 이건 틀린듯한데 어떻게 해야하나요?
$thumb = "uploads/images/mini/$row[image1]";
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
thumbnails::ResizeImage("uploads/images/$row[image1]", "uploads/images/mini/$row[image1]", 150);
}
else if (file_exists($thumb)) {
$img = "<img src='$thumb' height=54 border=0 style='border:1px solid #a1a1a1;margin-right:10px;'>";
}
else {
$img = "<img src='images/t.gif' border=0>";
}
print("<td width=10>$img</td>");
눈치껏 해봤는데 이건 틀린듯한데 어떻게 해야하나요?
17년 전
댓글로 작성하신 걸 기준으로 말씀드리면...
$thumb는 HTTP로 접근할 때의 경로가 됩니다. 즉, file_exists로는 검사할 수가 없죠.
file_exists("/home/mysite/www/" + $thumb) 같은 식으로 절대 경로를 앞에 추가하면 어떨까요?
$thumb는 HTTP로 접근할 때의 경로가 됩니다. 즉, file_exists로는 검사할 수가 없죠.
file_exists("/home/mysite/www/" + $thumb) 같은 식으로 절대 경로를 앞에 추가하면 어떨까요?
17년 전
P.S.
많은 PHP 프로그램들이 절대 경로를 넣은 변수 또는 define을 사용하거나,
dirname(__FILE__) 등을 활용해서 이 문제를 해결하고 있습니다.
많은 PHP 프로그램들이 절대 경로를 넣은 변수 또는 define을 사용하거나,
dirname(__FILE__) 등을 활용해서 이 문제를 해결하고 있습니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2030 | 17년 전 | 2786 | ||
| 2029 | 17년 전 | 1594 | ||
| 2028 | 17년 전 | 1343 | ||
| 2027 | 17년 전 | 1607 | ||
| 2026 |
진정한승리
|
17년 전 | 2518 | |
| 2025 | 17년 전 | 1733 | ||
| 2024 | 17년 전 | 2016 | ||
| 2023 | 17년 전 | 1303 | ||
| 2022 |
SE7EN
|
17년 전 | 1039 | |
| 2021 | 17년 전 | 1124 | ||
| 2020 | 17년 전 | 2924 | ||
| 2019 | 17년 전 | 2466 | ||
| 2018 | 17년 전 | 2048 | ||
| 2017 | 17년 전 | 2048 | ||
| 2016 | 17년 전 | 1794 | ||
| 2015 | 17년 전 | 2247 | ||
| 2014 | 17년 전 | 2013 | ||
| 2013 | 17년 전 | 1984 | ||
| 2012 | 17년 전 | 1868 | ||
| 2011 | 17년 전 | 1204 | ||
| 2010 | 17년 전 | 1821 | ||
| 2009 | 17년 전 | 2225 | ||
| 2008 | 17년 전 | 2296 | ||
| 2007 | 17년 전 | 1639 | ||
| 2006 |
Arone
|
17년 전 | 1507 | |
| 2005 |
|
17년 전 | 1353 | |
| 2004 | 17년 전 | 2572 | ||
| 2003 |
suerte
|
17년 전 | 2671 | |
| 2002 |
suerte
|
17년 전 | 2075 | |
| 2001 |
suerte
|
17년 전 | 2417 | |
| 2000 |
|
17년 전 | 2721 | |
| 1999 |
|
17년 전 | 1324 | |
| 1998 |
|
17년 전 | 1189 | |
| 1997 | 17년 전 | 6324 | ||
| 1996 | 17년 전 | 1177 | ||
| 1995 | 17년 전 | 1628 | ||
| 1994 | 17년 전 | 1776 | ||
| 1993 | 17년 전 | 1098 | ||
| 1992 | 17년 전 | 1188 | ||
| 1991 | 17년 전 | 1888 | ||
| 1990 |
sdjsu
|
17년 전 | 1517 | |
| 1989 | 17년 전 | 3614 | ||
| 1988 |
smilesol
|
17년 전 | 1203 | |
| 1987 |
|
17년 전 | 1903 | |
| 1986 | 17년 전 | 1168 | ||
| 1985 | 17년 전 | 1387 | ||
| 1984 | 17년 전 | 2358 | ||
| 1983 | 17년 전 | 2010 | ||
| 1982 | 17년 전 | 1034 | ||
| 1981 | 17년 전 | 1035 | ||
| 1980 | 17년 전 | 1085 | ||
| 1979 |
오렌지76
|
17년 전 | 6041 | |
| 1978 |
오렌지76
|
17년 전 | 5843 | |
| 1977 | 17년 전 | 2027 | ||
| 1976 |
없어씨바라
|
17년 전 | 1020 | |
| 1975 | 17년 전 | 1111 | ||
| 1974 | 17년 전 | 2078 | ||
| 1973 | 17년 전 | 1508 | ||
| 1972 | 17년 전 | 1151 | ||
| 1971 |
smilesol
|
17년 전 | 1180 | |
| 1970 | 17년 전 | 1127 | ||
| 1969 |
smilesol
|
17년 전 | 1055 | |
| 1968 |
소행성블루
|
17년 전 | 3964 | |
| 1967 |
소행성블루
|
17년 전 | 2176 | |
| 1966 | 17년 전 | 1629 | ||
| 1965 |
소행성블루
|
17년 전 | 2766 | |
| 1964 |
고양Ol아빠
|
17년 전 | 1470 | |
| 1963 | 17년 전 | 1152 | ||
| 1962 | 17년 전 | 1170 | ||
| 1961 |
choijinhee
|
17년 전 | 1241 | |
| 1960 | 17년 전 | 1125 | ||
| 1959 | 17년 전 | 1245 | ||
| 1958 |
하이웹솔루션
|
17년 전 | 2402 | |
| 1957 | 17년 전 | 4189 | ||
| 1956 | 17년 전 | 1189 | ||
| 1955 | 17년 전 | 3947 | ||
| 1954 | 17년 전 | 4098 | ||
| 1953 | 17년 전 | 1217 | ||
| 1952 | 17년 전 | 2171 | ||
| 1951 | 17년 전 | 1618 | ||
| 1950 | 17년 전 | 3211 | ||
| 1949 | 17년 전 | 1359 | ||
| 1948 | 17년 전 | 3608 | ||
| 1947 | 17년 전 | 3404 | ||
| 1946 | 17년 전 | 2573 | ||
| 1945 | 17년 전 | 2938 | ||
| 1944 | 17년 전 | 2624 | ||
| 1943 | 17년 전 | 1944 | ||
| 1942 | 17년 전 | 3312 | ||
| 1941 | 17년 전 | 2624 | ||
| 1940 | 17년 전 | 3518 | ||
| 1939 |
|
17년 전 | 1147 | |
| 1938 | 17년 전 | 2245 | ||
| 1937 | 17년 전 | 1318 | ||
| 1936 |
smilesol
|
17년 전 | 1184 | |
| 1935 |
AHEEZII
|
17년 전 | 1057 | |
| 1934 |
smilesol
|
17년 전 | 1042 | |
| 1933 | 17년 전 | 1417 | ||
| 1932 | 17년 전 | 2855 | ||
| 1931 | 17년 전 | 3250 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기