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 foreach my $name ( keys %$i ) {
40 if ( length($i->{$name}) == 0 || $i->{$name} =~ m{^(nema|n/a)$} ) {
45 if ( defined($i->{ukras}) ) {
46 my @ukrasi = split(/\s*,\s+|\s+i\s+/, $i->{ukras});
47 $i->{ukrasi_array} = [ @ukrasi ];
50 if ( defined($i->{očuvan_dio_posude} ) ) {
51 my @ocuvan = split(/\s*,\s+|\s+i\s+/, $i->{očuvan_dio_posude});
52 $i->{ocuvan_array} = [ @ocuvan ];
55 warn "# i = ",dump($i);
56 push @{ $json->{items} }, $i;
57 # foreach my $n ( 1 .. 1000 ) {
59 # $i2->{label} .= "_" . $n;
60 # push @{ $json->{items} }, $i2;
64 print $fh encode_json( $json );