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 = @imagecreatefro mjpeg($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 = @imagecreatetru ecolor ($twidth, $theight) or die ("Can't
resize!");
imagecopyresize d($thumb, $pic, 0, 0, 0, 0, $twidth, $theight, $width,
$height); // Resize to thumb
imagegammacorre ct($thumb, 1.0, 1.5);
ImageJPEG($thum b,$lagringssti .basename($filn avn1,'.jpg')
.."_thmb.jpg",1 00); // JPEG of thumb
// Make small image
$twidth = 230; // Vidde satt til 230 pixler
$theight = $twidth * $height / $width; // Regner ut høyden
$mediumPic = @imagecreatetru ecolor ($twidth, $theight) or die ("Can't
change size");
imagecopyresize d($mediumPic, $pic, 0, 0, 0, 0, $twidth, $theight, $width,
$height);
imageJPEG($medi umPic,$lagrings sti .basename($filn avn1,'.jpg')
.."_small.jpg", 100);
imagedestroy($t humb);
imagedestroy($m ediumPic);
// Delete the original file
list($stamme, $extension) = split("\.", $filnavn1);
unlink($lagring ssti .basename($filn avn1));
} // End: if ($pic)
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 = @imagecreatefro mjpeg($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 = @imagecreatetru ecolor ($twidth, $theight) or die ("Can't
resize!");
imagecopyresize d($thumb, $pic, 0, 0, 0, 0, $twidth, $theight, $width,
$height); // Resize to thumb
imagegammacorre ct($thumb, 1.0, 1.5);
ImageJPEG($thum b,$lagringssti .basename($filn avn1,'.jpg')
.."_thmb.jpg",1 00); // JPEG of thumb
// Make small image
$twidth = 230; // Vidde satt til 230 pixler
$theight = $twidth * $height / $width; // Regner ut høyden
$mediumPic = @imagecreatetru ecolor ($twidth, $theight) or die ("Can't
change size");
imagecopyresize d($mediumPic, $pic, 0, 0, 0, 0, $twidth, $theight, $width,
$height);
imageJPEG($medi umPic,$lagrings sti .basename($filn avn1,'.jpg')
.."_small.jpg", 100);
imagedestroy($t humb);
imagedestroy($m ediumPic);
// Delete the original file
list($stamme, $extension) = split("\.", $filnavn1);
unlink($lagring ssti .basename($filn avn1));
} // End: if ($pic)
Comment