diff --git a/lib/carrierwave/processing/mini_magick.rb b/lib/carrierwave/processing/mini_magick.rb index 86ec24ec2..f0b8d09e4 100644 --- a/lib/carrierwave/processing/mini_magick.rb +++ b/lib/carrierwave/processing/mini_magick.rb @@ -291,7 +291,7 @@ def manipulate! image = yield(image) FileUtils.mv image.path, current_path - image.run_command("identify", current_path) + ::MiniMagick::Image.new(current_path).identify rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e raise e if e.message =~ /(You must have .+ installed|is not installed|executable not found)/ message = I18n.translate(:"errors.messages.processing_error") diff --git a/spec/processing/mini_magick_spec.rb b/spec/processing/mini_magick_spec.rb index f0e4a5888..99ba3ad94 100644 --- a/spec/processing/mini_magick_spec.rb +++ b/spec/processing/mini_magick_spec.rb @@ -300,6 +300,14 @@ expect(instance).to be_format('png') end + it "returns the result of #identify on the manipulated image" do + expect( + instance.manipulate! do |image| + image.format('png') + end + ).to include 'landscape_copy.jpg PNG 640x480' + end + context "on failing to find ImageMagick/GraphicsMagick" do before do MiniMagick.remove_instance_variable(:@processor) if MiniMagick.instance_variable_defined?(:@processor) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e5bafbec1..099064e9a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -113,8 +113,12 @@ def change_and_enforce_available_locales(locale, available_locales, &block) module ManipulationHelpers def color_of_pixel(path, x, y) - image = ::MiniMagick::Image.open(path) - image.run_command("convert", "#{image.path}[1x1+#{x}+#{y}]", "-depth", "8", "txt:").split("\n")[1] + convert = ::MiniMagick::Tool::Convert.new + convert << path + convert.crop("1x1+#{x}+#{y}") + convert.depth(8) + convert << "txt:" + convert.call.split("\n")[1] end end