word: mkwordthumb script to recreate images
[sheet.git] / tools / mkwordthumb
1 #!/usr/bin/env perl
2 use 5.014;
3 use warnings;
4 use lib '.';
5 use Shiar_Sheet::ImagePrep;
6 use Shiar_Sheet::DB;
7
8 our $VERSION = '1.00';
9
10 my $db = Shiar_Sheet::DB->connect;
11 my %filter = @ARGV ? (id => shift) : ();
12 my $query = $db->select(word => '*', \%filter);
13
14 while (my $row = $query->hash) {
15         my $image = Shiar_Sheet::ImagePrep->new("data/word/org/$row->{id}.jpg");
16         eval {
17                 $image->convert("data/word/en/$row->{id}.jpg", $row->{thumb});
18         } or warn "$row->{id}: @{$@}";
19 }