FIX: optimized images were *not* optimized... (:fired:)
This commit is contained in:
parent
cb025a65e0
commit
555b5cb055
|
@ -150,19 +150,24 @@ class OptimizedImage < ActiveRecord::Base
|
||||||
method_name = "#{operation}_instructions"
|
method_name = "#{operation}_instructions"
|
||||||
method_name += "_animated" if !!opts[:allow_animation] && from =~ /\.GIF$/i
|
method_name += "_animated" if !!opts[:allow_animation] && from =~ /\.GIF$/i
|
||||||
instructions = self.send(method_name.to_sym, from, to, dim, opts)
|
instructions = self.send(method_name.to_sym, from, to, dim, opts)
|
||||||
convert_with(instructions)
|
convert_with(instructions, to)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.dimensions(width, height)
|
def self.dimensions(width, height)
|
||||||
"#{width}x#{height}"
|
"#{width}x#{height}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.convert_with(instructions)
|
def self.convert_with(instructions, to)
|
||||||
`convert #{instructions.join(" ")}`
|
`convert #{instructions.join(" ")}`
|
||||||
|
|
||||||
return false if $?.exitstatus != 0
|
return false if $?.exitstatus != 0
|
||||||
|
|
||||||
ImageOptim.new.optimize_image!(to) rescue nil
|
begin
|
||||||
|
ImageOptim.new.optimize_image!(to)
|
||||||
|
rescue => ex
|
||||||
|
Rails.logger.warn("Could not optimize image: #{to}")
|
||||||
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue