Image::Magick->Scale does nothing if given dimensions < 1, so make sure they are large enough when generating thumbnails in Storage/Image.pm

This commit is contained in:
Graham Knop 2007-04-17 22:00:59 +00:00
parent fc2086e10a
commit 886d8215b8
2 changed files with 7 additions and 1 deletions

View file

@ -8,6 +8,8 @@
http://www.plainblack.com/bugs/tracker/trouble-with-search-users
- fix: Fixed an unhandled exception in Workflow/Activity/PurgeOldAssetRevisions.pm
- Added better error handling for asset instanciation in version tags.
- fix: Image::Magick->Scale does nothing if given dimensions < 1, so make sure
they are large enough when generating thumbnails in Storage/Image.pm
7.3.14

View file

@ -133,7 +133,11 @@ sub generateThumbnail {
my $n = $thumbnailSize;
if ($x > $n || $y > $n) {
my $r = $x>$y ? $x / $n : $y / $n;
$image->Scale(width=>($x/$r),height=>($y/$r));
$x /= $r;
$y /= $r;
if($x < 1) { $x = 1 } # Dimentions < 1 cause Scale to fail
if($y < 1) { $y = 1 }
$image->Scale(width=>$x,height=>$y);
$image->Sharpen('0.0x1.0');
}
$error = $image->Write($self->getPath.'/'.'thumb-'.$filename);