convert new images, fill background
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 22 Jan 2021 16:28:34 +0000 (17:28 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 22 Jan 2021 16:28:34 +0000 (17:28 +0100)
csv2js.pl

index 4006be4..1b5af4a 100755 (executable)
--- 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};