+sub dimensions {
+ my ($imgpath) = @_;
+ require IPC::Run;
+ IPC::Run::run(
+ [identify => -format => '%w %h', $$imgpath],
+ '<' => \undef, '>&' => \my $xy
+ ) or die ["Image dimensions could not be determined.", $$imgpath];
+ return split /\s/, $xy, 3;
+}
+