From 5b6fc19e76b1b9af5c8ed1ebfa664606d2170e82 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 3 Oct 2019 01:09:12 +0200 Subject: port tootsuite#12057 to monsterfork: Fix performance of GIF re-encoding * Change animated GIF detection to not shell out to ImageMagick Signed-off-by: Eugen Rochko * Change video encoding parameters to limit to 10800 video frames Signed-off-by: Eugen Rochko * Limit GIF image size further Signed-off-by: Eugen Rochko * Always strip metadata from video files * Fix code style issues --- app/models/concerns/attachmentable.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/models/concerns/attachmentable.rb') diff --git a/app/models/concerns/attachmentable.rb b/app/models/concerns/attachmentable.rb index c3c7c7a35..9b3ca9e3c 100644 --- a/app/models/concerns/attachmentable.rb +++ b/app/models/concerns/attachmentable.rb @@ -6,6 +6,7 @@ module Attachmentable extend ActiveSupport::Concern MAX_MATRIX_LIMIT = 16_777_216 # 4096x4096px or approx. 16MB + GIF_MATRIX_LIMIT = 921_600 # 1280x720px included do before_post_process :obfuscate_file_name @@ -43,6 +44,7 @@ module Attachmentable next if attachment.blank? || !/image.*/.match?(attachment.content_type) || attachment.queued_for_write[:original].blank? width, height = FastImage.size(attachment.queued_for_write[:original].path) + matrix_limit = attachment.content_type == 'image/gif' ? GIF_MATRIX_LIMIT : MAX_MATRIX_LIMIT raise Mastodon::DimensionsValidationError, "#{width}x#{height} images are not supported" if width.present? && height.present? && (width * height >= MAX_MATRIX_LIMIT) end -- cgit