FIX: cropping GIF wasn't working

This commit is contained in:
Régis Hanol 2016-07-27 18:48:02 +02:00
parent 56d2626187
commit 11172b7c2d
2 changed files with 11 additions and 3 deletions

View file

@ -118,11 +118,11 @@ class OptimizedImage < ActiveRecord::Base
def self.resize_instructions_animated(from, to, dimensions, opts={}) def self.resize_instructions_animated(from, to, dimensions, opts={})
%W{ %W{
gifsicle gifsicle
#{from}
--colors=256 --colors=256
--resize-fit #{dimensions} --resize-fit #{dimensions}
--optimize=3 --optimize=3
--output #{to} --output #{to}
#{from}
} }
end end
@ -142,7 +142,14 @@ class OptimizedImage < ActiveRecord::Base
end end
def self.crop_instructions_animated(from, to, dimensions, opts={}) def self.crop_instructions_animated(from, to, dimensions, opts={})
resize_instructions_animated(from, to, dimensions, opts) %W{
gifsicle
--crop 0,0+#{dimensions}
--colors=256
--optimize=3
--output #{to}
#{from}
}
end end
def self.downsize_instructions(from, to, dimensions, opts={}) def self.downsize_instructions(from, to, dimensions, opts={})

View file

@ -28,7 +28,8 @@ module ImageSizer
return [w.floor, h.floor] if w <= max_width && h <= max_height return [w.floor, h.floor] if w <= max_width && h <= max_height
ratio = max_width / w ratio = max_width / w
[max_width.floor, [max_height, (h * ratio)].min.floor]
[[max_width, w].min.floor, [max_height, (h * ratio)].min.floor]
end end
end end