7 use Text::CSV qw( csv );
8 use Data::Dump qw( dump );
10 use Clone qw( clone );
15 my $file = 'keramika.csv';
16 my $aoh = csv (in => $file, headers => "auto");
18 open(my $fh, '>', 'keramika.js');
21 foreach my $i ( @$aoh ) {
22 my $source = sprintf( "../ZBIRKA-NEOLITIK/%d.png", $i->{ID} );
23 my $image = sprintf( "image/%d.jpg" , $i->{ID} );
24 my $thumb = sprintf( "thumb/%d.jpg" , $i->{ID} );
27 warn "ERROR: no image $source";
31 system "convert -trim -geometry 400x $source $image";
32 #system "convert $image -scale 100x100 -gravity center -background white -extent 100x100 $thumb";
33 system qq{convert $source -fill white -draw "color 1,1 floodfill" -scale 100x100 -gravity center -background white -extent 100x100 $thumb};
35 $i->{thumbnail} = $thumb;
36 # $i->{label} = $i->{opis_predmeta};
37 $i->{label} = $i->{ID};
39 my @ukrasi = split(/\s*,\s+|\s+i\s+/, $i->{ukras});
40 $i->{ukrasi_array} = [ @ukrasi ];
42 my @ocuvan = split(/\s*,\s+|\s+i\s+/, $i->{očuvan_dio_posude});
43 $i->{ocuvan_array} = [ @ocuvan ];
45 warn "# i = ",dump($i);
46 push @{ $json->{items} }, $i;
47 # foreach my $n ( 1 .. 1000 ) {
49 # $i2->{label} .= "_" . $n;
50 # push @{ $json->{items} }, $i2;
54 print $fh encode_json( $json );