Commit 3d0d49f5 by Tieg Zaharia Committed by Jon Yurek

add -layers 'optimize' flag to animated gif convert cmds

parent 42ca3985
...@@ -96,6 +96,7 @@ module Paperclip ...@@ -96,6 +96,7 @@ module Paperclip
trans << "-auto-orient" if auto_orient trans << "-auto-orient" if auto_orient
trans << "-resize" << %["#{scale}"] unless scale.nil? || scale.empty? trans << "-resize" << %["#{scale}"] unless scale.nil? || scale.empty?
trans << "-crop" << %["#{crop}"] << "+repage" if crop trans << "-crop" << %["#{crop}"] << "+repage" if crop
trans << "-layers \"optimize\"" if animated?
trans trans
end end
......
...@@ -381,12 +381,16 @@ class ThumbnailTest < Test::Unit::TestCase ...@@ -381,12 +381,16 @@ class ThumbnailTest < Test::Unit::TestCase
should "create the 12 frames thumbnail when sent #make" do should "create the 12 frames thumbnail when sent #make" do
dst = @thumb.make dst = @thumb.make
cmd = %Q[identify -format "%wx%h" "#{dst.path}"] cmd = %Q[identify -format "%wx%h" "#{dst.path}"]
assert_equal "50x50"*12, `#{cmd}`.chomp assert_equal ("50x5050x5050x5050x5050x5050x49")*2, `#{cmd}`.chomp
end end
should "use the -coalesce option" do should "use the -coalesce option" do
assert_equal @thumb.transformation_command.first, "-coalesce" assert_equal @thumb.transformation_command.first, "-coalesce"
end end
should "use the -layers 'optimize' option" do
assert_equal @thumb.transformation_command.last, '-layers "optimize"'
end
end end
context "with omitted output format" do context "with omitted output format" do
...@@ -397,12 +401,16 @@ class ThumbnailTest < Test::Unit::TestCase ...@@ -397,12 +401,16 @@ class ThumbnailTest < Test::Unit::TestCase
should "create the 12 frames thumbnail when sent #make" do should "create the 12 frames thumbnail when sent #make" do
dst = @thumb.make dst = @thumb.make
cmd = %Q[identify -format "%wx%h" "#{dst.path}"] cmd = %Q[identify -format "%wx%h" "#{dst.path}"]
assert_equal "50x50"*12, `#{cmd}`.chomp assert_equal ("50x5050x5050x5050x5050x5050x49")*2, `#{cmd}`.chomp
end end
should "use the -coalesce option" do should "use the -coalesce option" do
assert_equal @thumb.transformation_command.first, "-coalesce" assert_equal @thumb.transformation_command.first, "-coalesce"
end end
should "use the -layers 'optimize' option" do
assert_equal @thumb.transformation_command.last, '-layers "optimize"'
end
end end
context "with unidentified source format" do context "with unidentified source format" do
...@@ -414,12 +422,17 @@ class ThumbnailTest < Test::Unit::TestCase ...@@ -414,12 +422,17 @@ class ThumbnailTest < Test::Unit::TestCase
should "create the 12 frames thumbnail when sent #make" do should "create the 12 frames thumbnail when sent #make" do
dst = @thumb.make dst = @thumb.make
cmd = %Q[identify -format "%wx%h" "#{dst.path}"] cmd = %Q[identify -format "%wx%h" "#{dst.path}"]
assert_equal "60x60"*12, `#{cmd}`.chomp assert_equal "60x6059x5959x5959x5960x5959x5859x6059x5959x5959x5960x5959x58", `#{cmd}`.chomp
end end
should "use the -coalesce option" do should "use the -coalesce option" do
assert_equal @thumb.transformation_command.first, "-coalesce" assert_equal @thumb.transformation_command.first, "-coalesce"
end end
should "use the -layers 'optimize' option" do
assert_equal @thumb.transformation_command.last, '-layers "optimize"'
end
end end
context "with no source format" do context "with no source format" do
...@@ -431,12 +444,16 @@ class ThumbnailTest < Test::Unit::TestCase ...@@ -431,12 +444,16 @@ class ThumbnailTest < Test::Unit::TestCase
should "create the 12 frames thumbnail when sent #make" do should "create the 12 frames thumbnail when sent #make" do
dst = @thumb.make dst = @thumb.make
cmd = %Q[identify -format "%wx%h" "#{dst.path}"] cmd = %Q[identify -format "%wx%h" "#{dst.path}"]
assert_equal "70x70"*12, `#{cmd}`.chomp assert_equal "70x7067x6867x6868x6769x6767x6768x6967x6867x6868x6769x6767x67", `#{cmd}`.chomp
end end
should "use the -coalesce option" do should "use the -coalesce option" do
assert_equal @thumb.transformation_command.first, "-coalesce" assert_equal @thumb.transformation_command.first, "-coalesce"
end end
should "use the -layers 'optimize' option" do
assert_equal @thumb.transformation_command.last, '-layers "optimize"'
end
end end
context "with animated option set to false" do context "with animated option set to false" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment