[Koha-bugs] [Bug 35520] Add a script to export images from the db

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Dec 8 12:16:10 CET 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35520

--- Comment #2 from Magnus Enger <magnus at libriotech.no> ---
Here's a very basic POC, just for cover images. Feel free to build on it if you
can beat me to it! :-) 

use Koha::CoverImages;
use File::Slurper qw( write_binary );
use Modern::Perl;

my $outputdir = '.';

my $covers = Koha::CoverImages->search();
while ( my $cover = $covers->next ) {

    my $biblionumber = $cover->biblionumber;
    my $imagenumber = $cover->imagenumber;
    my $itemnumber = $cover->itemnumber; # Can be NULL

    my $filename = "$outputdir/biblionumber_$biblionumber" .
"_imagenumber_$imagenumber" . "_full.png";
    write_binary( $filename, $cover->imagefile );
    say "Wrote $filename";

    my $thumbnail = "$outputdir/biblionumber_$biblionumber" .
"_imagenumber_$imagenumber" . "_thumb.png";
    write_binary( $thumbnail, $cover->thumbnail );
    say "Wrote $thumbnail";

}

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list