Skip to content

Commit

Permalink
Fixed bugs with 1.8.7/ree
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanzeeb Khalili committed Apr 10, 2012
1 parent 3120a5d commit 9c766ee
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 9c766ee

Please sign in to comment.