Storage/Image: resize works with ImageMagick again. Add diagnostics to tests for easy debug

This commit is contained in:
Colin Kuskie 2007-12-19 18:04:50 +00:00
parent 182f3ecfae
commit 8d1e47a6ce
2 changed files with 15 additions and 9 deletions

View file

@ -382,14 +382,14 @@ sub resize {
$self->session->errorHandler->error("Couldn't read image for resizing: ".$error);
return 0;
}
my $geometry;
if (!$width || !$height) {
$geometry = $width || $height;
}
else {
$geometry = $width . "x" . $height;
my ($x, $y) = $image->Get('width','height');
if (!$height) { # proportional scale by width
$height = $width / $x * $y;
}
$image->Resize( geometry => $geometry, filter => "lanczos" );
elsif (!$width) { # proportional scale by height
$width = $height * $x / $y;
}
$image->Resize( height => $height, width => $width, filter => "lanczos" );
$error = $image->Write($self->getPath($filename));
if ($error) {
$self->session->errorHandler->error("Couldn't resize image: ".$error);

View file

@ -259,16 +259,22 @@ foreach my $testImage (@testImages) {
);
}
use Data::Dumper;
$session->setting->set('maxImageSize', $resizeTarget );
foreach my $testImage (@testImages) {
my $filename = $testImage->{ filename };
#diag $filename;
#diag "orig size: ". Dumper([ $sizeTest->getSizeInPixels($filename) ]);
is($sizeTest->adjustMaxImageSize($filename), 1, "$filename needs to be resized");
my @newSize = $sizeTest->getSizeInPixels($filename);
diag sprintf("%s -> new size = %d x %d", $filename, @newSize);
#diag sprintf("%s -> new size = %d x %d", $filename, @newSize);
#diag $WebGUI::Test::logger_warns;
#diag $WebGUI::Test::logger_error;
cmp_bag(
[ $sizeTest->getSizeInPixels($filename) ],
[ @{ $testImage }{qw/newHeight newWidth/} ],
"$testImage was resized properly"
"$filename was resized properly"
);
}