Don't generate max preview twice

If you request a preview of X by Y. And after calculating X and Y are
equal to maxWidth and maxHeight then there is no reason to create a
preview of that size.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2017-03-19 20:23:23 +01:00
parent 6677963902
commit 4cd13e7668
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 5 additions and 0 deletions

View File

@ -111,6 +111,11 @@ class Generator {
// Calculate the preview size
list($width, $height) = $this->calculateSize($width, $height, $crop, $mode, $maxWidth, $maxHeight);
// No need to generate a preview that is just the max preview
if ($width === $maxWidth && $height === $maxHeight) {
return $maxPreview;
}
// Try to get a cached preview. Else generate (and store) one
try {
$file = $this->getCachedPreview($previewFolder, $width, $height, $crop);