Posted on 2009-09-22 14:49:54-07 by cnighswonger
copyResized VS copyResampled: Both appear to adversely affect image quality
Using the latest version of GD there appears to be no quality difference between these two methods. Here are the relevant lines of code. The resulting jpeg is several magnitudes lower in quality than the original png. Using copyResized gives nearly exactly the same results. Am I missing something?
my $image = GD::Image->newFromPngData($image_data->{'imagefile'}); my ($orig_width, $orig_height) = $image->getBounds(); my $bound_ratio = 0.25; my $height = sprintf("%.0f", ($orig_height*$bound_ratio)); my $width = sprintf("%.0f", ($orig_width*$bound_ratio)); my $blob = GD::Image->new($width,$height); $blob->copyResampled($image,0,0,0,0,$width,$height,$orig_width,$orig_height); $layout->{'images'}->{$_}->{'Sx'} = $width; $layout->{'images'}->{$_}->{'Sy'} = $height; $layout->{'images'}->{$_}->{'data'} = $blob->jpeg(100);
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.