X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/e327cdf7ff4bb2ce54fead5b7fcc480d4a3cec3e..c4af187b7b7518a0810e90f8fd79caba84ac0d34:/tools/mkimgthumb diff --git a/tools/mkimgthumb b/tools/mkimgthumb index fc33162..8f0097a 100755 --- a/tools/mkimgthumb +++ b/tools/mkimgthumb @@ -1,6 +1,8 @@ #!/usr/bin/env perl use 5.014; use warnings; +use lib $0 =~ s{[^/]+$}{..}r; # project root +use Shiar_Sheet::ImagePrep '1.03'; my $failcount = 0; @@ -21,11 +23,18 @@ for my $src (@ARGV) { if @crop > 2; unshift @cmds, -chop => "$crop[0]%x$crop[1]%"; } - unshift @cmds, -gravity => 'northwest' if @cmds; - push @cmds, -resize => '300x200^', -gravity => 'north', -extent => '300x200'; - push @cmds, '-strip', -quality => '60%'; - system(convert => $src, @cmds, "../$name.jpg") == 0 - or $failcount += warn "error creating $name.jpg from $src\n"; + push @cmds, -gravity => 'north'; + my @cmdwebp = (-resize => '630x420^', -extent => '630x420', -quality => 30); + my @cmdjpeg = (-resize => '300x200^', -extent => '300x200'); + eval { + my $image = Shiar_Sheet::ImagePrep->new($src); + $image->convert("../$name.jpg", [@cmds, @cmdjpeg]); + $image->convert("../$name.webp", [@cmds, @cmdwebp]); + } or do { + warn "error creating image:\n"; + warn ref $@ eq 'ARRAY' ? $@->[1] : $@ if $@; + $failcount++; + }; } exit $failcount;