From 2dedeb06e0af682d257ed4b3c63c837e8f3e1e39 Mon Sep 17 00:00:00 2001 From: Matthew Barbour Date: Fri, 28 Aug 2020 09:15:45 -0500 Subject: [PATCH] Added "Fit Blur Tall, Fill Wide" resize type --- core/imageboard/misc.php | 7 ++++++- ext/media/main.php | 9 +++++++++ ext/media/media_engine.php | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/core/imageboard/misc.php b/core/imageboard/misc.php index 888aae0c..6e13527d 100644 --- a/core/imageboard/misc.php +++ b/core/imageboard/misc.php @@ -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)]; } diff --git a/ext/media/main.php b/ext/media/main.php index 769e1b56..ded7e462 100644 --- a/ext/media/main.php +++ b/ext/media/main.php @@ -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: diff --git a/ext/media/media_engine.php b/ext/media/media_engine.php index 711fdc97..5f1d8a39 100644 --- a/ext/media/media_engine.php +++ b/ext/media/media_engine.php @@ -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, ],