Hej ! Do tworzenia miniaturek uzywam tego skryptu:
<?
function createThumb($sfile,$dfile)
{
// the passed variables are string filenames, the source and the destination
global $maxwidth,$maxheight;
$simg = imagecreatefromjpeg($sfile);
$currwidth=imagesx($simg);
$currheight=imagesy($simg);
//set the dimensions of the thumbnail
if ($currheight>$currwidth*1.7)
{
$zoom=$maxheight/$currheight;
$newheight=$maxheight;
$newwidth=$currwidth*$zoom;
}
else
{
$zoom=$maxwidth/$currwidth;
$newwidth=$maxwidth;
$newheight=$currheight*$zoom;
}
//create the resource img for the thumbnail
$dimg = imagecreate($newwidth, $newheight);
//convert truecolor immage resource to palette image resource (so we can count the colors...)
imagetruecolortopalette($simg, false, 256);
$palsize = ImageColorsTotal($simg);
for ($i = 0; $i<$palsize; $i++)
{
$colors = ImageColorsForIndex($simg, $i);
ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']);
}
imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight);
imagejpeg($dimg,$dfile);
ImageDestroy($simg);
ImageDestroy($dimg);
}
?>
mam jednak problem z jakoscia miniaturek. Myslalem ze ustaienie kompresji na 95 cos pomoze ale nic - dalej sa slabe - bo wsyztsko rozbija sie o sam mechanizm resize'u. Poniewaz nie znam dobrze tych polecen prosze o pomoc. Zainteresowac sie zupelnie innym skryptem czy poprawiac ten ? czy: imagecreatetruecolor cos tu pomoze ?
pozdrawiam