Bugzilla – Attachment 151781 Details for
Bug 33857
Reduce and resize local cover images
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33857: Resize local cover images
Bug-33857-Add-script-to-resize-cover-images.patch (text/plain), 2.74 KB, created by
Hinemoea Viault
on 2023-05-29 16:48:54 UTC
(
hide
)
Description:
Bug 33857: Resize local cover images
Filename:
MIME Type:
Creator:
Hinemoea Viault
Created:
2023-05-29 16:48:54 UTC
Size:
2.74 KB
patch
obsolete
>From 046c7f59534fddf76475a11babb24f30b1151f6e Mon Sep 17 00:00:00 2001 >From: Hinemoea Viault <hinemoea.viault@inlibro.com> >Date: Mon, 29 May 2023 12:18:34 -0400 >Subject: [PATCH] Bug 33857: Add script to resize cover images > >--- > misc/maintenance/resize_cover_images.pl | 74 +++++++++++++++++++++++++ > 1 file changed, 74 insertions(+) > create mode 100755 misc/maintenance/resize_cover_images.pl > >diff --git a/misc/maintenance/resize_cover_images.pl b/misc/maintenance/resize_cover_images.pl >new file mode 100755 >index 0000000000..6f9df99d7b >--- /dev/null >+++ b/misc/maintenance/resize_cover_images.pl >@@ -0,0 +1,74 @@ >+ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright 2019 Koha Development Team >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+ >+use Modern::Perl; >+ >+use CGI qw ( -utf8 ); >+ >+use Koha::CoverImages; >+use Image::Magick; #sudo apt install imagemagick >+$| = 1; >+ >+my @images = Koha::CoverImages->as_list(); >+my $image; >+my $i =0; >+print "Vous avez " . scalar @images . " images. \n"; >+ >+my $dbh = C4::Context->dbh; >+my $sth = $dbh->prepare("SELECT round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` FROM information_schema.TABLES WHERE table_schema = '$ENV{'KOHADB'}' AND table_name = 'cover_images';"); >+$sth->execute(); >+my @test = $sth->fetchrow_array(); >+print "La taile de tout les images dans $ENV{'KOHADB'} est de ". $test[0]. "MG avant.\n"; >+ print "[..........] 0-1000 images \r ["; >+for ( @images ) { >+ $i++; >+ #print $i ."\n"; >+ my $im = Image::Magick->new; >+ $image = ""; >+ >+ $im->BlobToImage($_->imagefile); >+ $im->Resize( geometry => '300x400' ); >+ >+ $image = $im->ImageToBlob(); >+ >+ >+ $_->update( >+ {imagefile => $image} >+ ); >+ >+ if($i % 100 == 0) >+ { >+ print "*"; >+ if($i % 1000 == 0){ >+ print "]\r[..........] $i-".($i+1000)." images \r ["; >+ } >+ } >+} >+print "\n". $i . " images traité.\n"; >+my $query = "optimize table cover_images"; >+ >+ my $sthOp = $dbh->prepare($query); >+ >+$sthOp->execute; >+ >+$sth->execute(); >+@test = $sth->fetchrow_array(); >+print "La taile de tout les images dans $ENV{'KOHADB'} est de ". $test[0]. "MG apres.\n"; >\ No newline at end of file >-- >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 33857
:
151780
|
151781
|
151810
|
152307
|
152308
|
152313
|
171103