Skip to content

Commit

Permalink
Merge pull request #693 from xtreme-tanzeeb-khalili/master
Browse files Browse the repository at this point in the history
Add more sophisticated multi-page PDF support (Ruby 1.8.7 fix)
  • Loading branch information
bensie committed Apr 10, 2012
2 parents ed1b899 + 9c766ee commit 38f9ccc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/carrierwave/processing/rmagick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,20 +243,24 @@ def resize_and_pad(width, height, background=:transparent, gravity=::Magick::Cen
#
# [CarrierWave::ProcessingError] if manipulation failed.
#
def manipulate!(options={})
def manipulate!(options={}, &block)
cache_stored_file! if !cached?
image = ::Magick::Image.read(current_path)

frames = if image.size > 1
list = ::Magick::ImageList.new
image.each_with_index do |frame, index|
processed_frame = block_given? ? yield( frame, index ) : frame
processed_frame = if block_given?
yield *[frame, index].take(block.arity)
else
frame
end
list << processed_frame if processed_frame
end
block_given? ? list : list.append(true)
else
frame = image.first
frame = yield( frame, 0 ) if block_given?
frame = yield( *[frame, 0].take(block.arity) ) if block_given?
frame
end

Expand Down

0 comments on commit 38f9ccc

Please sign in to comment.