[Bug 33674] New: Landscape cover images are resized ignoring if image/book cover width > height
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33674 Bug ID: 33674 Summary: Landscape cover images are resized ignoring if image/book cover width > height Change sponsored?: --- Product: Koha Version: 21.11 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Cataloging Assignee: koha-bugs@lists.koha-community.org Reporter: steve@softwaremage.co.nz QA Contact: testopia@bugs.koha-community.org CC: m.de.rooy@rijksmuseum.nl The code fragments below (/Koha/CoverImage.pm) need to determine if the width is greater than the height before resizing and creating the thumbnails and 'fullsize' image version. Otherwise wide books are always resized as if they were tall books. As a result the thumbnails and fullsize images of wide books are always scaled smaller than their 'portrait' counterparts. Needless to say these hardcoded values should be part of system preferences. They were set before the days of 4K monitors. I think that might be an open item. sub new { my ( $class, $params ) = @_; my $src_image = delete $params->{src_image}; if ( $src_image ) { ; # GD autodetects three basic image formats: PNG, JPEG, XPM; we will convert all to PNG which is lossless... # Check the pixel size of the image we are about to import... my $thumbnail = $class->_scale_image( $src_image, 140, 200 ) ; # MAX pixel dims are 140 X 200 for thumbnail... my $fullsize = $class->_scale_image( $src_image, 600, 800 ) ; # MAX pixel dims are 600 X 800 for full-size image... $params->{mimetype} = 'image/png'; $params->{imagefile} = $fullsize->png(); $params->{thumbnail} = $thumbnail->png(); } return $class->SUPER::new($params); } sub _scale_image { my ( $self, $image, $maxwidth, $maxheight ) = @_; my ( $width, $height ) = $image->getBounds(); if ( $width > $maxwidth || $height > $maxheight ) { my $percent_reduce; # Percent we will reduce the image dimensions by... if ( $width > $maxwidth ) { $percent_reduce = sprintf( "%.5f", ( $maxwidth / $width ) ) ; # If the width is oversize, scale based on width overage... } else { $percent_reduce = sprintf( "%.5f", ( $maxheight / $height ) ) ; # otherwise scale based on height overage. } my $width_reduce = sprintf( "%.0f", ( $width * $percent_reduce ) ); my $height_reduce = sprintf( "%.0f", ( $height * $percent_reduce ) ); my $newimage = GD::Image->new( $width_reduce, $height_reduce, 1 ) ; #'1' creates true color image... $newimage->copyResampled( $image, 0, 0, 0, 0, $width_reduce, $height_reduce, $width, $height ); return $newimage; } else { return $image; } } -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33674 Esther Melander <esther.melander@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |esther.melander@bywatersolu | |tions.com --- Comment #1 from Esther Melander <esther.melander@bywatersolutions.com> --- Created attachment 190810 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=190810&action=edit Cover image variations Looking at the code, it appears the images are processed so that the dimensions are adjusted by a percentage rather than forcing them into the dimensions of 140 X 200 or 600 x 800 as described in the Koha manual. The percentage adjustment seems correct so that the aspect ratio of the original image is not altered. However, this processing results in an inconsistent display in the OPAC if the original images are all different sizes. It seems like the images should be adjusted to fit within a container that maintains the same space in search result listings and the bibliographic detail view. See the attached image where different image sizes were uploaded resulting in a variation in the space used for the listing. The flexibility of the current code allows for the user to upload images with a variety of dimensions, but should there be consistency in the display regardless? Also, perhaps the Koha manual should be updated to indicate recommended image dimensions and/or clarify images are processed by percentage rather than fixed dimensions. While this is a bit of a side tangent from the original, the uploaded image example does seem to illustrate the problem of an image in landscape mode with the third listing as it does appear small in comparison to the other images in a portrait orientation. It's also not clear if this processing applies to individual image uploads or batch image uploads (at least from the manual). -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33674 Nick G <n.gagnon@dover.nh.gov> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |n.gagnon@dover.nh.gov -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33674 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=41509 CC| |david@davidnind.com --- Comment #2 from David Nind <david@davidnind.com> --- Happy to update the manual, if we can get some consensus on what the recommended sizes are (and that match up with how Koha actually works). -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org