FIX: use correct command line attribute for `gifsicle` while scale down the gif.

FIX: use correct command line attribute for gifsicle while scale down the gif.

diff --git a/app/models/optimized_image.rb b/app/models/optimized_image.rb
index 3f5614a..e578353 100644
--- a/app/models/optimized_image.rb
+++ b/app/models/optimized_image.rb
@@ -236,11 +236,12 @@ class OptimizedImage < ActiveRecord::Base
 
   def self.resize_instructions_animated(from, to, dimensions, opts = {})
     ensure_safe_paths!(from, to)
+    resize_method = opts[:scale_image] ? "scale" : "resize-fit"
 
     %W{
       gifsicle
       --colors=#{opts[:colors] || 256}
-      --resize-fit #{dimensions}
+      --#{resize_method} #{dimensions}
       --optimize=3
       --output #{to}
       #{from}
diff --git a/lib/upload_creator.rb b/lib/upload_creator.rb
index d9c21f1..b806e2f 100644
--- a/lib/upload_creator.rb
+++ b/lib/upload_creator.rb
@@ -245,14 +245,16 @@ class UploadCreator
 
       from = @file.path
       to = down_tempfile.path
+      scale = (from =~ /\.GIF$/i) ? "0.5" : "50%"
 
       OptimizedImage.ensure_safe_paths!(from, to)
 
       OptimizedImage.downsize(
         from,
         to,
-        "50%",
+        scale,
         allow_animation: allow_animation,
+        scale_image: true,
         raise_on_error: true
       )
 

GitHub sha: b57d4586

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/uploaded-animated-gifs-of-4mb-or-larger-appear-very-small/147107/11