diff --git a/lib/carrierwave/test/matchers.rb b/lib/carrierwave/test/matchers.rb index cf4057667..e2bdb24dd 100644 --- a/lib/carrierwave/test/matchers.rb +++ b/lib/carrierwave/test/matchers.rb @@ -336,6 +336,8 @@ class ImageLoader # :nodoc: def self.load_image(filename) if defined? ::MiniMagick MiniMagickWrapper.new(filename) + elsif defined? ::Vips + VipsWrapper.new(filename) else unless defined? ::Magick begin @@ -393,6 +395,28 @@ def initialize(filename) end end + class VipsWrapper # :nodoc: + attr_reader :image + + def width + image.width + end + + def height + image.height + end + + def format + # This returns the name of the vips loader (e.g. pngload) as Vips + # doesn't do content detection. + image.get("vips-loader").delete_suffix("load") + end + + def initialize(filename) + @image = ::Vips::Image.new_from_file(filename) + end + end + end # Matchers end # Test end # CarrierWave