($src) = grep {-e} glob qq<"$name"{,:*}.$ext> or next;
}
say $name;
- unshift @cmds, -gravity => 'northwest';
+
+ if (@cmds and $cmds[0] =~ /^\d/) {
+ # crop shorthand from initial dimension argument
+ my @crop = split /\D/, shift @cmds;
+ unshift @cmds, -gravity => 'southeast', -chop => "$crop[2]%x$crop[3]%"
+ 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 => @cmds, $src => "../$name.jpg") == 0