4 use lib $0 =~ s{[^/]+$}{..}r; # project root
5 use Shiar_Sheet::ImagePrep '1.03';
11 if (@ARGV and $ARGV[0] =~ /^-/) {
13 Getopt::Long->import(qw( 2.33 :config gnu_getopt ));
27 push @ffs, my $ff = [$_];
29 push @{$ff}, -quality => $1 if $r =~ s/@(\d+)//;
30 push @{$ff}, -resize => !/\dx\d+$/ ? $_ : ("$_^", -extent => $_)
35 $target = pop @ARGV if @ARGV >= 2 and -d $ARGV[-1];
40 my ($name, @cmds) = split /:(?<!\\:)/, $src =~ s/\.(\w+)\z//r;
43 next if $name =~ m/\./;
45 ($src) = grep {-e} glob qq<"$name"{,:*}.$ext> or next;
47 s/\\(.)/$1/g for @cmds;
50 if (@cmds and $cmds[0] =~ /^\d/) {
51 # crop shorthand from initial dimension argument
52 my @crop = split /\D/, shift @cmds;
53 unshift @cmds, -gravity => 'southeast', -chop => "$crop[2]%x$crop[3]%"
55 unshift @cmds, -chop => "$crop[0]%x$crop[1]%";
57 push @cmds, -gravity => 'north';
59 my $image = Shiar_Sheet::ImagePrep->new($src);
61 my ($ff, @ffcmds) = @{$_};
63 $image->convert("$target/$name.$ff", [@cmds, @ffcmds]);
68 warn ref $@ eq 'ARRAY' ? $@->[1] : $@ if $@;