1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#!/usr/bin/perl
#
# (C) 2012 Matthew Gates
#
use strict;
use warnings;
use File::Basename;
my $gs_prog = basename $0;
if ($#ARGV<0) {
usage(1);
}
else {
foreach (@ARGV) {
if (/^(--help|-h)$/) { usage(0); }
}
}
open(ID, '-|', 'identify', @ARGV) || die "cannot execute identify (perhaps ImageMagick is not installed?)\n";
while(<ID>) {
my ($imgfile, undef, $dimensions, undef) = split(/\s+/);
$imgfile =~ s/\[\d+\]$//;
my ($w, $h) = split("x", $dimensions);
if (log2($w) != int(log2($w)) || log2($h) != int(log2($h))) {
printf "ERROR: non-integer power of 2 dimension for %-30s (%4d x %4d)\n", $imgfile, $w, $h, log2($w), log2($h);
}
}
close(ID);
sub usage {
my $el = shift || 0;
print <<EOD;
Usage:
$gs_prog imagefilename [imagefilename] ...
If any of the specified image files have dimensions which might be a problem for OpenGL,
they are printed with a suitable warning message.
Note: this program expects the ImageMagick binary "identify" to be available and in the
PATH.
EOD
exit($el);
}
sub log2 {
my $n = shift;
return log($n)/log(2);
}
|