From f424f99b532b722e6094276cc40589af3a40cc7a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 5 Aug 2019 11:51:34 -0500 Subject: [PATCH] Bug 22988: Always set trueColor for the fullsize image --- C4/Images.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/C4/Images.pm b/C4/Images.pm index 856e894d8a..ebc9ed687b 100644 --- a/C4/Images.pm +++ b/C4/Images.pm @@ -75,7 +75,7 @@ sub PutImage { # Check the pixel size of the image we are about to import... my $thumbnail = _scale_image( $srcimage, 140, 200 ) ; # MAX pixel dims are 140 X 200 for thumbnail... - my $fullsize = _scale_image( $srcimage, 600, 800 ) + my $fullsize = _scale_image( $srcimage, 600, 800, { force_true_color => 1 } ) ; # MAX pixel dims are 600 X 800 for full-size image... $debug and warn "thumbnail is " . length($thumbnail) . " bytes."; @@ -156,9 +156,11 @@ sub DelImage { } sub _scale_image { - my ( $image, $maxwidth, $maxheight ) = @_; + my ( $image, $maxwidth, $maxheight, $params ) = @_; my ( $width, $height ) = $image->getBounds(); $debug and warn "image is $width pix X $height pix."; + + my $true_color = delete $params->{force_true_color} || $image->trueColor; if ( $width > $maxwidth || $height > $maxheight ) { # $debug and warn "$filename exceeds the maximum pixel dimensions of $maxwidth X $maxheight. Resizing..."; @@ -179,7 +181,7 @@ sub _scale_image { and warn "Reducing image by " . ( $percent_reduce * 100 ) . "\% or to $width_reduce pix X $height_reduce pix"; - my $newimage = GD::Image->new( $width_reduce, $height_reduce, $image->trueColor ) + my $newimage = GD::Image->new( $width_reduce, $height_reduce, $true_color) ; # if third is set, creates true color image $newimage->copyResampled( $image, 0, 0, 0, 0, $width_reduce, $height_reduce, $width, $height ); -- 2.11.0