From b806859bbbcce84427a3e90537197b7354b39af7 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 22 Jan 2021 17:28:34 +0100 Subject: [PATCH] convert new images, fill background --- csv2js.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/csv2js.pl b/csv2js.pl index 4006be4..1b5af4a 100755 --- a/csv2js.pl +++ b/csv2js.pl @@ -8,6 +8,7 @@ use Text::CSV qw( csv ); use Data::Dump qw( dump ); use JSON; use Clone qw( clone ); +use autodie; use utf8; @@ -18,11 +19,18 @@ open(my $fh, '>', 'keramika.js'); my $json; foreach my $i ( @$aoh ) { - my $source = sprintf( "ZBIRKA-NEOLITIK/%02d.png", $i->{ID} ); + my $source = sprintf( "../ZBIRKA-NEOLITIK/%d.png", $i->{ID} ); my $image = sprintf( "image/%d.jpg" , $i->{ID} ); my $thumb = sprintf( "thumb/%d.jpg" , $i->{ID} ); - system "convert -trim $source $image"; - system "convert -geometry 100x $image $thumb"; + + if ( ! -e $source ) { + warn "ERROR: no image $source"; + next; + } + + system "convert -trim -geometry 400x $source $image"; + #system "convert $image -scale 100x100 -gravity center -background white -extent 100x100 $thumb"; + system qq{convert $source -fill white -draw "color 1,1 floodfill" -scale 100x100 -gravity center -background white -extent 100x100 $thumb}; $i->{image} = $image; $i->{thumbnail} = $thumb; # $i->{label} = $i->{opis_predmeta}; -- 2.20.1