Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

#47: Multipage PDFs fixed by Pete Deffendol

  • Loading branch information...
commit 06f9b99e5f00627b7fe1377db0dc996a3eada655 1 parent 8a43c13
Jon Yurek jyurek authored
2  lib/paperclip/geometry.rb
View
@@ -16,7 +16,7 @@ def initialize width = nil, height = nil, modifier = nil
def self.from_file file
file = file.path if file.respond_to? "path"
geometry = begin
- Paperclip.run("identify", %Q[-format "%wx%h" "#{file}"])
+ Paperclip.run("identify", %Q[-format "%wx%h" "#{file}"[0]])
rescue PaperclipCommandLineError
""
end
BIN  test/fixtures/twopage.pdf
View
Binary file not shown
33 test/thumbnail_test.rb
View
@@ -141,4 +141,37 @@ class ThumbnailTest < Test::Unit::TestCase
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
Please sign in to comment.
Something went wrong with that request. Please try again.