Bug 8088: Png-images of covers lost transparency
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 Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
3af877e78a
commit
22a13ba009
|
|
@ -75,6 +75,8 @@ sub new {
|
|||
sub _scale_image {
|
||||
my ( $self, $image, $maxwidth, $maxheight ) = @_;
|
||||
my ( $width, $height ) = $image->getBounds();
|
||||
$image->alphaBlending(0);
|
||||
$image->saveAlpha(1);
|
||||
if ( $width > $maxwidth || $height > $maxheight ) {
|
||||
|
||||
my $percent_reduce; # Percent we will reduce the image dimensions by...
|
||||
|
|
@ -86,11 +88,11 @@ sub _scale_image {
|
|||
}
|
||||
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
|
||||
);
|
||||
my $newimage = GD::Image->new( $width_reduce, $height_reduce, 1 )
|
||||
; #'1' creates true color image...
|
||||
$newimage->alphaBlending(0);
|
||||
$newimage->saveAlpha(1);
|
||||
$newimage->copyResampled( $image, 0, 0, 0, 0, $width_reduce, $height_reduce, $width, $height );
|
||||
return $newimage;
|
||||
} else {
|
||||
return $image;
|
||||
|
|
|
|||
|
|
@ -103,6 +103,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 ) {
|
||||
|
|
@ -186,7 +187,8 @@ 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/ ) {
|
||||
if ( $full_filename =~ /^\Q$dir\E/ ){
|
||||
GD::Image->trueColor(1);
|
||||
$srcimage = GD::Image->new($full_filename);
|
||||
}
|
||||
my $biblio;
|
||||
|
|
|
|||
Loading…
Reference in New Issue