By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

resized images give crappy quality - why?

P: n/a
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)
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I noticed that Message-ID: <40******@news.broadpark.no> from Dag
Eilertsen contained the following:
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?


Use imagecopyresampled()
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2

P: n/a
Use ImageMagick, not GD

"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:0i********************************@4ax.com...
I noticed that Message-ID: <40******@news.broadpark.no> from Dag
Eilertsen contained the following:
The script below resizes images into two different sizes. My problem is thatthe quality of the resized images is poor. Any idea how to improve my
script?


Use imagecopyresampled()
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Jul 17 '05 #3

P: n/a
I noticed that Message-ID:
<2W********************@news20.bellglobal.com> from Alex contained the
following:
Use ImageMagick, not GD


Users don't always have a choice.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.