Bugzilla – Attachment 176536 Details for
Bug 8088
Png-images of covers lost transparency
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8088: Png-images of covers lost transparency
Bug-8088-Png-images-of-covers-lost-transparency.patch (text/plain), 3.24 KB, created by
Hammat wele
on 2025-01-14 20:10:11 UTC
(
hide
)
Description:
Bug 8088: Png-images of covers lost transparency
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2025-01-14 20:10:11 UTC
Size:
3.24 KB
patch
obsolete
>From ac0f3a19f210bdbc3d2b302c3120e84a55ce8615 Mon Sep 17 00:00:00 2001 >From: Hammat Wele <hammat.wele@inlibro.com> >Date: Tue, 14 Jan 2025 20:09:41 +0000 >Subject: [PATCH] Bug 8088: Png-images of covers lost transparency >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Images of covers must preserve transparency of png-images. This is useful for example for the covers of CD/DVD disks. > >Plan test : >1. Apply the patch. >2. In 'Koha administration > System preferences', set 'LocalCoverImages' to 'show' and OPACLocalCoverImages to 'show'. >3. Create a new bibligraphical record >4. In the record details select tab Images and click on upload >5. click on « Drop files here » and select the image file to upload then click «Process images» >6. Search for the record created on step 3 >7. Click on the record to view detail page (detail.pl) >8. Click on the image to view it fully > --->Notice the background is transparent >9. Save the image and open it > ---> Notice the background is transparent >--- > Koha/CoverImage.pm | 8 ++++++-- > tools/upload-cover-image.pl | 2 ++ > 2 files changed, 8 insertions(+), 2 deletions(-) > >diff --git a/Koha/CoverImage.pm b/Koha/CoverImage.pm >index e5467bedeb..36508c08ca 100644 >--- a/Koha/CoverImage.pm >+++ b/Koha/CoverImage.pm >@@ -75,6 +75,9 @@ sub new { > sub _scale_image { > my ( $self, $image, $maxwidth, $maxheight ) = @_; > my ( $width, $height ) = $image->getBounds(); >+ my $background = $image->colorAllocate(0,0,0); >+ $image->alphaBlending(0); >+ $image->saveAlpha(1); > if ( $width > $maxwidth || $height > $maxheight ) { > > my $percent_reduce; # Percent we will reduce the image dimensions by... >@@ -92,8 +95,9 @@ sub _scale_image { > 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 ); >+ $newimage->alphaBlending(0); >+ $newimage->saveAlpha(1); >+ $newimage->copyResampled( $image, 0, 0, 0, 0, $width_reduce, $height_reduce, $width, $height ); > return $newimage; > } > else { >diff --git a/tools/upload-cover-image.pl b/tools/upload-cover-image.pl >index e78f360947..1ec7ffe1f6 100755 >--- a/tools/upload-cover-image.pl >+++ b/tools/upload-cover-image.pl >@@ -102,6 +102,7 @@ if ( $op eq 'cud-process' && $fileID ) { > my $upload = Koha::UploadedFiles->find( $fileID ); > if ( $filetype eq 'image' ) { > my $fh = $upload->file_handle; >+ GD::Image->trueColor(1); > my $srcimage = GD::Image->new($fh); > $fh->close if $fh; > if ( defined $srcimage ) { >@@ -190,6 +191,7 @@ if ( $op eq 'cud-process' && $fileID ) { > my $full_filename = Cwd::abs_path("$dir/$filename"); #Resolve any relative filepath references > my $srcimage; > if ( $full_filename =~ /^\Q$dir\E/ ){ >+ GD::Image->trueColor(1); > $srcimage = GD::Image->new($full_filename); > } > my $biblio; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8088
:
9573
|
175852
|
175853
|
175964
|
176278
|
176536
|
176537