Allow uploads of images up to 8000x8000 but shrink to 2000x2000

This commit is contained in:
Christoph Haas 2021-02-18 02:00:34 +01:00
parent 3116fb6b4d
commit aca9df2910

View file

@ -4,7 +4,7 @@
class ImageUploader < Shrine class ImageUploader < Shrine
ALLOWED_TYPES = %w[image/jpeg image/png image/webp] ALLOWED_TYPES = %w[image/jpeg image/png image/webp]
MAX_SIZE = 5*1024*1024 # 5 MB MAX_SIZE = 5*1024*1024 # 5 MB
MAX_DIMENSIONS = [4000, 4000] # 2000x2000 MAX_DIMENSIONS = [8000, 8000] # larger than 2000x2000 will be resized
plugin :remove_attachment plugin :remove_attachment
plugin :pretty_location plugin :pretty_location
@ -29,7 +29,7 @@ class ImageUploader < Shrine
thumb: magick.resize_to_limit!(160,120), thumb: magick.resize_to_limit!(160,120),
small: magick.resize_to_limit!(320, 240), small: magick.resize_to_limit!(320, 240),
#medium: magick.resize_to_limit!(800, 600), #medium: magick.resize_to_limit!(800, 600),
large: magick.composite!('public/logo/watermark.png', gravity: 'east') large: magick.resize_to_limit(2000,2000).composite!('public/logo/watermark.png', gravity: 'east')
} }
# GenerateThumbnail.call(original, width, height) # lib/generate_thumbnail.rb # GenerateThumbnail.call(original, width, height) # lib/generate_thumbnail.rb