diff --git a/app/logical/danbooru_image_resizer.rb b/app/logical/danbooru_image_resizer.rb index a62ddc290..4101d843a 100644 --- a/app/logical/danbooru_image_resizer.rb +++ b/app/logical/danbooru_image_resizer.rb @@ -36,6 +36,8 @@ module DanbooruImageResizer end def self.crop_ruby(file, width, height, resize_quality) + return nil unless Danbooru.config.enable_image_cropping + output_file = Tempfile.new resized_image = Vips::Image.thumbnail(file.path, width, height: height, **CROP_OPTIONS) resized_image.jpegsave(output_file.path, Q: resize_quality, **JPEG_OPTIONS) @@ -66,6 +68,8 @@ module DanbooruImageResizer end def self.crop_shell(file, width, height, quality) + return nil unless Danbooru.config.enable_image_cropping + output_file = Tempfile.new(["crop", ".jpg"]) # --size=WxH will upscale if the image is smaller than the target size. diff --git a/app/logical/pixiv_ugoira_converter.rb b/app/logical/pixiv_ugoira_converter.rb index 6d645a879..7179406db 100644 --- a/app/logical/pixiv_ugoira_converter.rb +++ b/app/logical/pixiv_ugoira_converter.rb @@ -65,6 +65,8 @@ class PixivUgoiraConverter end def self.generate_crop(ugoira_file) + return nil unless Danbooru.config.enable_image_cropping + file = Tempfile.new(["ugoira-crop", ".zip"], binmode: true) zipfile = Zip::File.new(ugoira_file.path) zipfile.entries.first.extract(file.path) { true } # 'true' means overwrite the existing tempfile. diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 2b3417251..0e22866ae 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -21,7 +21,7 @@ class PostPresenter < Presenter end path = options[:path_prefix] || "/posts" - if CurrentUser.id == 1 && options[:show_cropped] && post.has_cropped? && !CurrentUser.user.disable_cropped_thumbnails? + if Danbooru.config.enable_image_cropping && CurrentUser.id == 1 && options[:show_cropped] && post.has_cropped? && !CurrentUser.user.disable_cropped_thumbnails? src = post.crop_file_url imgClass = "cropped" else diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index cd0abb994..25c629298 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -762,6 +762,10 @@ module Danbooru def recaptcha_secret_key end + + def enable_image_cropping + true + end # Akismet API key. Used for Dmail spam detection. http://akismet.com/signup/ def rakismet_key