word: mkwordthumb script to recreate images
[sheet.git] / tools / mkwordthumb
diff --git a/tools/mkwordthumb b/tools/mkwordthumb
new file mode 100755 (executable)
index 0000000..6d1ac67
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/env perl
+use 5.014;
+use warnings;
+use lib '.';
+use Shiar_Sheet::ImagePrep;
+use Shiar_Sheet::DB;
+
+our $VERSION = '1.00';
+
+my $db = Shiar_Sheet::DB->connect;
+my %filter = @ARGV ? (id => shift) : ();
+my $query = $db->select(word => '*', \%filter);
+
+while (my $row = $query->hash) {
+       my $image = Shiar_Sheet::ImagePrep->new("data/word/org/$row->{id}.jpg");
+       eval {
+               $image->convert("data/word/en/$row->{id}.jpg", $row->{thumb});
+       } or warn "$row->{id}: @{$@}";
+}