Merge pull request #746 from sanmadjack/resize_types

Added "Fit Blur Tall, Fill Wide" resize type
This commit is contained in:
Shish 2020-09-16 11:20:28 +01:00 committed by GitHub
commit 5d86314fc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View file

@ -75,7 +75,12 @@ function get_thumbnail_size(int $orig_width, int $orig_height, bool $use_dpi_sca
$fit = $config->get_string(ImageConfig::THUMB_FIT);
if (in_array($fit, [Media::RESIZE_TYPE_FILL, Media::RESIZE_TYPE_STRETCH, Media::RESIZE_TYPE_FIT_BLUR])) {
if (in_array($fit, [
Media::RESIZE_TYPE_FILL,
Media::RESIZE_TYPE_STRETCH,
Media::RESIZE_TYPE_FIT_BLUR,
Media::RESIZE_TYPE_FIT_BLUR_PORTRAIT
])) {
return [$config->get_int(ImageConfig::THUMB_WIDTH), $config->get_int(ImageConfig::THUMB_HEIGHT)];
}

View file

@ -34,6 +34,7 @@ class Media extends Extension
public const RESIZE_TYPE_FIT = "Fit";
public const RESIZE_TYPE_FIT_BLUR = "Fit Blur";
public const RESIZE_TYPE_FIT_BLUR_PORTRAIT = "Fit Blur Tall, Fill Wide";
public const RESIZE_TYPE_FILL = "Fill";
public const RESIZE_TYPE_STRETCH = "Stretch";
public const DEFAULT_ALPHA_CONVERSION_COLOR = "#00000000";
@ -586,6 +587,14 @@ class Media extends Extension
$file_arg = "${input_ext}:\"${input_path}[0]\"";
if($resize_type===Media::RESIZE_TYPE_FIT_BLUR_PORTRAIT) {
if($new_height>$new_width) {
$resize_type = Media::RESIZE_TYPE_FIT_BLUR;
} else {
$resize_type = Media::RESIZE_TYPE_FILL;
}
}
switch ($resize_type) {
case Media::RESIZE_TYPE_FIT:
case Media::RESIZE_TYPE_STRETCH:

View file

@ -83,6 +83,7 @@ abstract class MediaEngine
MediaEngine::IMAGICK => [
Media::RESIZE_TYPE_FIT,
Media::RESIZE_TYPE_FIT_BLUR,
Media::RESIZE_TYPE_FIT_BLUR_PORTRAIT,
Media::RESIZE_TYPE_FILL,
Media::RESIZE_TYPE_STRETCH,
],