fix thumbnail script with Graphics::Magick, other cleanups

This commit is contained in:
Graham Knop 2007-09-06 16:11:39 +00:00
parent 3d43273d58
commit b64102a91f
3 changed files with 27 additions and 16 deletions

View file

@ -15,9 +15,21 @@
use File::stat;
use File::Find ();
use Image::Magick;
use Getopt::Long;
my $graphicsPackage;
BEGIN {
if (eval { require Graphics::Magick; 1 }) {
$graphicsPackage = 'Graphics::Magick';
}
elsif (eval { require Image::Magick; 1 }) {
$graphicsPackage = 'Image::Magick';
}
else {
croak "You must have either Graphics::Magick or Image::Magick installed to run WebGUI.\n";
}
}
use lib "../lib";
use WebGUI::Utility;
@ -74,7 +86,7 @@ sub createThumbnail {
my ($image, $x, $y, $r, $n, $type);
my ($fileName, $fileDir) = @_;
print "Nailing: $fileDir/$fileName\n";
$image = Image::Magick->new;
$image = $graphicsPackage->new;
$image->Read($fileName);
($x, $y) = $image->Get('width','height');
$r = $x>$y ? $x / $thumbnailSize : $y / $thumbnailSize;