Commit 06f9b99e by Jon Yurek

#47: Multipage PDFs fixed by Pete Deffendol

parent 8a43c13e
...@@ -16,7 +16,7 @@ module Paperclip ...@@ -16,7 +16,7 @@ module Paperclip
def self.from_file file def self.from_file file
file = file.path if file.respond_to? "path" file = file.path if file.respond_to? "path"
geometry = begin geometry = begin
Paperclip.run("identify", %Q[-format "%wx%h" "#{file}"]) Paperclip.run("identify", %Q[-format "%wx%h" "#{file}"[0]])
rescue PaperclipCommandLineError rescue PaperclipCommandLineError
"" ""
end end
......
...@@ -141,4 +141,37 @@ class ThumbnailTest < Test::Unit::TestCase ...@@ -141,4 +141,37 @@ class ThumbnailTest < Test::Unit::TestCase
end end
end end
end end
context "A multipage PDF" do
setup do
@file = File.new(File.join(File.dirname(__FILE__), "fixtures", "twopage.pdf"), 'rb')
end
teardown { @file.close }
should "start with two pages with dimensions 612x792" do
cmd = %Q[identify -format "%wx%h" "#{@file.path}"]
assert_equal "612x792"*2, `#{cmd}`.chomp
end
context "being thumbnailed at 100x100 with cropping" do
setup do
@thumb = Paperclip::Thumbnail.new(@file, :geometry => "100x100#", :format => :png)
end
should "report its correct current and target geometries" do
assert_equal "100x100#", @thumb.target_geometry.to_s
assert_equal "612x792", @thumb.current_geometry.to_s
end
should "report its correct format" do
assert_equal :png, @thumb.format
end
should "create the thumbnail when sent #make" do
dst = @thumb.make
assert_match /100x100/, `identify "#{dst.path}"`
end
end
end
end 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