The script below resizes images into two different sizes. My problem is that
the quality of the resized images is poor. Any idea how to improve my
script? The users are only uploading jpg's.
Thanks!
Dag Eilertsen
__________________________________________________ __________________________
_
$bilde = "./" .$lagringssti .$filnavn1;
$pic = @imagecreatefromjpeg($bilde) or die("Sorry!");
if ($pic)
{
// Make thumb
$width = imagesx($pic);
$height = imagesy($pic);
$twidth = 100;
$theight = $twidth * $height / $width; // Regner ut høyden
$thumb = @imagecreatetruecolor ($twidth, $theight) or die ("Can't
resize!");
imagecopyresized($thumb, $pic, 0, 0, 0, 0, $twidth, $theight, $width,
$height); // Resize to thumb
imagegammacorrect($thumb, 1.0, 1.5);
ImageJPEG($thumb,$lagringssti .basename($filnavn1,'.jpg')
.."_thmb.jpg",100); // JPEG of thumb
// Make small image
$twidth = 230; // Vidde satt til 230 pixler
$theight = $twidth * $height / $width; // Regner ut høyden
$mediumPic = @imagecreatetruecolor ($twidth, $theight) or die ("Can't
change size");
imagecopyresized($mediumPic, $pic, 0, 0, 0, 0, $twidth, $theight, $width,
$height);
imageJPEG($mediumPic,$lagringssti .basename($filnavn1,'.jpg')
.."_small.jpg",100);
imagedestroy($thumb);
imagedestroy($mediumPic);
// Delete the original file
list($stamme, $extension) = split("\.", $filnavn1);
unlink($lagringssti .basename($filnavn1));
} // End: if ($pic)