| |
|
|
| | Здравствуйте! У меня такая проблема: я скачал скрипт превьюшек, размер 100 на 100.Если использую другие размеры к примеру 200 на 200, то если размер оригинальной фотографии не дотягивает до них - фотка не показывается, т.е. наверно, должно быть условие: если оринальные размеры меньше 200 на 200 т.е выводится оринанальные размеры?
Ниже приводится скрипт:
<?php
$filename = $_GET['file'];
resizeimg($filename, 200,200);
function resizeimg($filename, $w, $h)
{
$filename = $filename;
$ratio = $w/$h;
$size_img = getimagesize($filename);
if (($size_img[0]<$w) && ($size_img[1]<$h)) return true;
$src_ratio=$size_img[0]/$size_img[1];
if ($ratio<$src_ratio)
{
$h = $w/$src_ratio;
} else
{
$w = $h*$src_ratio+1;
}
$dest_img = imagecreatetruecolor($w, $h);
$white = imagecolorallocate($dest_img, 255, 255, 255);
if ($size_img[2]==2) $src_img = imagecreatefromjpeg($filename);
elseif ($size_img[2]==1) $src_img = imagecreatefromgif($filename);
elseif ($size_img[2]==3) $src_img = imagecreatefrompng($filename);
imagecopyresampled($dest_img, $src_img, 0, 0, 0, 0, $w, $h, $size_img[0], $size_img[1]);
if ($size_img[2]==2) {header('Content-type: image/jpg'); imagejpeg($dest_img);}
elseif ($size_img[2]==1) {header('Content-type: image/gif'); imagegif($dest_img);}
elseif ($size_img[2]==3) {header('Content-type: image/png'); imagepng($dest_img);}
imagedestroy($dest_img);
imagedestroy($src_img);
return true;
}
?>
|
| |
| |
|
|
| |
|
|
| |
для: ronin
(23.04.2007 в 12:54)
| | | Скачай мой срипт, там я вроди бы решал эту проблему...
http://rolly.od.ua/files/download/bs2_photo_review1.0.3-win32.zip
там в скрипте поковыряйся...
bs2 photo review version 1.0.3
What's a bs2 photo review? The Program for output of the scenes in on web page. This application can serve as photo gallery, or web photo archive. The Program supports the formats JPEG, JPG, PNG, GIF. By means of GD libraries, the program will die to reduce the present size a photo in small to publish on web page.
Download: bs2_photo_review1.0.3-win32.zip (56 kb) | for Win32 / PHP4
Вот DOC: http://rolly.od.ua/files/scripts/bs2_photo_review/readme.txt | |
| |
|
|
| |
|
|
| |
для: gkhelloworld
(24.04.2007 в 08:17)
| | | Спасибо! Скачал, буду разбираться... | |
| |
|
|