Mailinglisten-Archive |
Hallo Liste,
ich erzeuge derzeit mit der GD2-Lib ein .jpg-Bild mit der folgenden
Funktion:
<CODE>
function createJPGThumb($sfile,$dfile, $maxWidth, $maxHeight, $imagetype)
{
// the passed variables are string filenames, the source and the
destination
switch($imagetype) {
case 'image/gif':
$simg = imagecreatefromgif($sfile);
$image = 1;
break;
case 'image/jpeg':
case 'image/pjpeg':
$simg = imagecreatefromjpeg($sfile);
$image = 1;
break;
case 'image/png':
$simg = imagecreatefrompng($sfile);
$image = 1;
break;
}//end switch
if ($image == 1) {
$currwidth=imagesx($simg);
$currheight=imagesy($simg);
$newwidth = $currwidth;
$newheight = $currheight;
//set the dimensions of the thumbnail
if ($currheight>$maxHeight) {
$faktor = $currwidth / $currheight;
$newheight = intval($maxHeight);
$newwidth = intval($maxHeight * $faktor);
}//end if
if ($currwidth>$maxWidth) {
$faktor = $currheight / $currwidth;
$newwidth = intval($maxWidth);
$newheight = intval($maxWidth * $faktor);
}//end if
if ($newheight>$maxHeight) {
$faktor = $currwidth / $currheight;
$newheight = intval($maxHeight);
$newwidth = intval($maxHeight * $faktor);
}//end if
if ($newwidth>$maxWidth) {
$faktor = $currheight / $currwidth;
$newwidth = intval($maxWidth);
$newheight = intval($maxWidth * $faktor);
}//end if
//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);
}
}
</CODE>
Mein Problem ist, dass wenn ein Bild einen Schlagschatten beinhält,
dieser leider nicht richtig im End-Bild dargestellt wird.
Wie kann ich die Qualität des Ergebnisses so verbessern, dass die Bilder
in 1a-Qualität sind?
Vielen Dank
Michael
php::bar PHP Wiki - Listenarchive