From 5a26de0e1a2021298316df91e119f798c2753136 Mon Sep 17 00:00:00 2001 From: Oleg Vivtash Date: Thu, 14 Jun 2018 13:57:45 +0300 Subject: [PATCH] Check if image responds to :read --- lib/prawn/images.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/prawn/images.rb b/lib/prawn/images.rb index 168e6f3f0..75fd45adb 100644 --- a/lib/prawn/images.rb +++ b/lib/prawn/images.rb @@ -137,11 +137,11 @@ def embed_image(pdf_obj, info, options) def verify_and_open_image(io_or_path) # File or IO - if io_or_path.respond_to?(:rewind) + if io_or_path.respond_to?(:read) io = io_or_path # Rewind if the object we're passed is an IO, so that multiple embeds of # the same IO object will work - io.rewind + io.rewind if io.respond_to?(:rewind) # read the file as binary so the size is calculated correctly # guard binmode because some objects acting io-like don't implement it io.binmode if io.respond_to?(:binmode)