Commit 01e50714 by jyurek

Cleaned up modifier handling.

git-svn-id: https://svn.thoughtbot.com/plugins/paperclip/trunk@421 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
parent e559ce8e
......@@ -60,7 +60,7 @@ module Paperclip
# Returns the width and height in a format suitable to be passed to Geometry.parse
def to_s
"%dx%d" % [width, height]
"%dx%d%s" % [width, height, modifier]
end
# Same as to_s
......
......@@ -59,8 +59,8 @@ module Paperclip
# into the thumbnail.
def transformation_command
scale, crop = @current_geometry.transformation_to(@target_geometry, crop?)
trans = "-scale #{scale}"
trans << " -crop #{crop} +repage" if crop
trans = "-scale \"#{scale}\""
trans << " -crop \"#{crop}\" +repage" if crop
trans
end
end
......
......@@ -59,6 +59,12 @@ class GeometryTest < Test::Unit::TestCase
end
end
should "make sure the modifier gets passed during transformation_to" do
assert @src = Paperclip::Geometry.parse("123x456")
assert @dst = Paperclip::Geometry.parse("123x456>")
assert_equal "123x456>", @src.transformation_to(@dst).to_s
end
should "be generated from a file" do
file = Dir.glob("/Users/jyurek/Pictures/*.jpg").first
file = File.new(file)
......
......@@ -20,11 +20,14 @@ class PaperclipTest < Test::Unit::TestCase
assert @dummy.valid?
assert @dummy.save
assert_equal "100x15", `identify -format "%wx%h" #{@dummy.avatar.to_io.path}`.chomp
assert_equal "434x66", `identify -format "%wx%h" #{@dummy.avatar.to_io(:original).path}`.chomp
assert_equal "300x46", `identify -format "%wx%h" #{@dummy.avatar.to_io(:large).path}`.chomp
assert_equal "100x15", `identify -format "%wx%h" #{@dummy.avatar.to_io(:medium).path}`.chomp
assert_equal "32x32", `identify -format "%wx%h" #{@dummy.avatar.to_io(:thumb).path}`.chomp
[["100x15", nil],
["434x66", :original],
["300x46", :large],
["100x15", :medium],
["32x32", :thumb]].each do |geo, style|
cmd = %Q[identify -format "%wx%h" #{@dummy.avatar.to_io(style).path}]
assert_equal geo, `#{cmd}`.chomp, cmd
end
saved_paths = [:thumb, :medium, :large, :original].collect{|s| @dummy.avatar.to_io(s).path }
......
......@@ -48,7 +48,7 @@ class ThumbnailTest < Test::Unit::TestCase
end
should "report its correct current and target geometries" do
assert_equal "100x50", @thumb.target_geometry.to_s
assert_equal "100x50#", @thumb.target_geometry.to_s
assert_equal "434x66", @thumb.current_geometry.to_s
end
......@@ -62,7 +62,7 @@ class ThumbnailTest < Test::Unit::TestCase
should "send the right command to convert when sent #make" do
@thumb.expects(:system).with do |arg|
arg.match %r{convert\s+"#{File.expand_path(@thumb.file.path)}"\s+-scale\s+x50\s+-crop\s+100x50\+114\+0\s+\+repage\s+".*?"}
arg.match %r{convert\s+"#{File.expand_path(@thumb.file.path)}"\s+-scale\s+\"x50\"\s+-crop\s+\"100x50\+114\+0\"\s+\+repage\s+".*?"}
end
@thumb.make
end
......
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