make image cropping optional
This commit is contained in:
@@ -36,6 +36,8 @@ module DanbooruImageResizer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.crop_ruby(file, width, height, resize_quality)
|
def self.crop_ruby(file, width, height, resize_quality)
|
||||||
|
return nil unless Danbooru.config.enable_image_cropping
|
||||||
|
|
||||||
output_file = Tempfile.new
|
output_file = Tempfile.new
|
||||||
resized_image = Vips::Image.thumbnail(file.path, width, height: height, **CROP_OPTIONS)
|
resized_image = Vips::Image.thumbnail(file.path, width, height: height, **CROP_OPTIONS)
|
||||||
resized_image.jpegsave(output_file.path, Q: resize_quality, **JPEG_OPTIONS)
|
resized_image.jpegsave(output_file.path, Q: resize_quality, **JPEG_OPTIONS)
|
||||||
@@ -66,6 +68,8 @@ module DanbooruImageResizer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.crop_shell(file, width, height, quality)
|
def self.crop_shell(file, width, height, quality)
|
||||||
|
return nil unless Danbooru.config.enable_image_cropping
|
||||||
|
|
||||||
output_file = Tempfile.new(["crop", ".jpg"])
|
output_file = Tempfile.new(["crop", ".jpg"])
|
||||||
|
|
||||||
# --size=WxH will upscale if the image is smaller than the target size.
|
# --size=WxH will upscale if the image is smaller than the target size.
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ class PixivUgoiraConverter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.generate_crop(ugoira_file)
|
def self.generate_crop(ugoira_file)
|
||||||
|
return nil unless Danbooru.config.enable_image_cropping
|
||||||
|
|
||||||
file = Tempfile.new(["ugoira-crop", ".zip"], binmode: true)
|
file = Tempfile.new(["ugoira-crop", ".zip"], binmode: true)
|
||||||
zipfile = Zip::File.new(ugoira_file.path)
|
zipfile = Zip::File.new(ugoira_file.path)
|
||||||
zipfile.entries.first.extract(file.path) { true } # 'true' means overwrite the existing tempfile.
|
zipfile.entries.first.extract(file.path) { true } # 'true' means overwrite the existing tempfile.
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class PostPresenter < Presenter
|
|||||||
end
|
end
|
||||||
|
|
||||||
path = options[:path_prefix] || "/posts"
|
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
|
src = post.crop_file_url
|
||||||
imgClass = "cropped"
|
imgClass = "cropped"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -762,6 +762,10 @@ module Danbooru
|
|||||||
|
|
||||||
def recaptcha_secret_key
|
def recaptcha_secret_key
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def enable_image_cropping
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
# Akismet API key. Used for Dmail spam detection. http://akismet.com/signup/
|
# Akismet API key. Used for Dmail spam detection. http://akismet.com/signup/
|
||||||
def rakismet_key
|
def rakismet_key
|
||||||
|
|||||||
Reference in New Issue
Block a user