lib/carrierwave/processing/rmagick.rb in carrierwave-1.3.4 vs lib/carrierwave/processing/rmagick.rb in carrierwave-2.0.0.rc

- old
+ new

@@ -226,11 +226,11 @@ def resize_and_pad(width, height, background=:transparent, gravity=::Magick::CenterGravity) width = dimension_from width height = dimension_from height manipulate! do |img| img.resize_to_fit!(width, height) - new_img = ::Magick::Image.new(width, height) { |img| img.background_color = background == :transparent ? 'rgba(255,255,255,0)' : background.to_s } + 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 @@ -361,11 +361,11 @@ write_block = create_info_block(options[:write]) if options[:format] || @format frames.write("#{options[:format] || @format}:#{current_path}", &write_block) move_to = current_path.chomp(File.extname(current_path)) + ".#{options[:format] || @format}" - file.content_type = ::MIME::Types.type_for(move_to).first.to_s + file.content_type = ::MiniMime.lookup_by_filename(move_to).content_type file.move_to(move_to, permissions, directory_permissions) else frames.write(current_path, &write_block) end @@ -376,18 +376,12 @@ private def create_info_block(options) return nil unless options - proc do |img| - options.each do |k, v| - if v.is_a?(String) && (matches = v.match(/^["'](.+)["']/)) - ActiveSupport::Deprecation.warn "Passing quoted strings like #{v} to #manipulate! is deprecated, pass them without quoting." - v = matches[1] - end - img.public_send(:"#{k}=", v) - end - end + assignments = options.map { |k, v| "self.#{k} = #{v}" } + code = "lambda { |img| " + assignments.join(";") + "}" + eval code end def destroy_image(image) image.try(:destroy!) end