Refactor out the copied code to resize images based on the max file

size from the Admin Settings and create a new method in
Storage::Image.
Build a test to verify that it works correctly.
This commit is contained in:
Colin Kuskie 2007-11-24 05:30:15 +00:00
parent 41a8524daf
commit 1b3d7f0c2b
5 changed files with 74 additions and 32 deletions

View file

@ -230,16 +230,7 @@ sub processPropertiesFromFormPost {
my $storage = $self->getStorageLocation;
foreach my $file (@{$storage->getFiles}) {
if ($storage->isImage($file)) {
my ($w, $h) = $storage->getSizeInPixels($file);
my $max_size = $self->session->setting->get("maxImageSize");
if($w > $max_size || $h > $max_size) {
if($w > $h) {
$storage->resize($file, $max_size);
}
else {
$storage->resize($file, 0, $max_size);
}
}
$storage->adjustMaxImageSize($size);
}
$size += $storage->getFileSize($file);
}