lib/carrierwave/processing/rmagick.rb in carrierwave-0.9.0 vs lib/carrierwave/processing/rmagick.rb in carrierwave-0.10.0

- old
+ new

@@ -60,12 +60,10 @@ module RMagick extend ActiveSupport::Concern included do begin - require "rmagick" - rescue LoadError require "RMagick" rescue LoadError => e e.message << " (You may need to install the rmagick gem)" raise e end @@ -213,11 +211,11 @@ # [Magick::Image] additional manipulations to perform # def resize_and_pad(width, height, background=:transparent, gravity=::Magick::CenterGravity) manipulate! do |img| img.resize_to_fit!(width, height) - new_img = ::Magick::Image.new(width, height) { self.background_color = 'rgba(255,255,255,0)' } + new_img = ::Magick::Image.new(width, height) { self.background_color = background == :transparent ? 'rgba(255,255,255,0)' : background.to_s } if background == :transparent filled = new_img.matte_floodfill(1, 1) else filled = new_img.color_floodfill(1, 1, ::Magick::Pixel.from_color(background)) end @@ -313,26 +311,16 @@ def manipulate!(options={}, &block) cache_stored_file! if !cached? read_block = create_info_block(options[:read]) image = ::Magick::Image.read(current_path, &read_block) + frames = ::Magick::ImageList.new - frames = if image.size > 1 - list = ::Magick::ImageList.new - image.each_with_index do |frame, index| - processed_frame = if block_given? - yield *[frame, index, options].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, options].take(block.arity) ) if block_given? - frame + image.each_with_index do |frame, index| + frame = yield *[frame, index, options].take(block.arity) if block_given? + frames << frame if frame end + frames.append(true) if block_given? write_block = create_info_block(options[:write]) if options[:format] || @format frames.write("#{options[:format] || @format}:#{current_path}", &write_block) else