Only resize photos if they are larger than the Gallery resolutions.
This commit is contained in:
parent
b54308626b
commit
a894bf906a
2 changed files with 10 additions and 3 deletions
|
|
@ -22,6 +22,7 @@ use Image::ExifTool qw( :Public );
|
|||
use JSON qw/ encode_json decode_json /;
|
||||
use URI::Escape;
|
||||
use Tie::IxHash;
|
||||
use List::MoreUtils;
|
||||
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::Friends;
|
||||
|
|
@ -360,14 +361,19 @@ sub makeResolutions {
|
|||
my $storage = $self->getStorageLocation;
|
||||
$self->session->errorHandler->info(" Making resolutions for '" . $self->get("filename") . q{'});
|
||||
|
||||
for my $res ( @$resolutions ) {
|
||||
my $filename = $self->get('filename');
|
||||
RESOLUTION: for my $res ( @$resolutions ) {
|
||||
# carp if resolution is bad
|
||||
if ( $res !~ /^\d+$/ && $res !~ /^\d*x\d*/ ) {
|
||||
carp "Geometry '$res' is invalid. Skipping.";
|
||||
next;
|
||||
next RESOLUTION;
|
||||
}
|
||||
##Only resize images if the image is too big!
|
||||
my ($imageX, $imageY) = $storage->getSizeInPixels($filename);
|
||||
my @resolutions = split /x/, $res;
|
||||
next RESOLUTION if List::MoreUtils::any { $imageX < $_ && $imageY < $_ } @resolutions;
|
||||
my $newFilename = $res . ".jpg";
|
||||
$storage->copyFile( $self->get("filename"), $newFilename );
|
||||
$storage->copyFile( $filename, $newFilename );
|
||||
$storage->resize( $newFilename, $res, undef, $self->getGallery->get( 'imageDensity' ) );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue