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

This commit is contained in:
Vinoth Kannan 2020-04-10 18:16:47 +05:30
parent 3e10d4133d
commit b57d4586d7
2 changed files with 5 additions and 2 deletions

View File

@ -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}

View File

@ -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
)