Method: Informers::Utils::RawImage.read

Defined in:
lib/informers/utils/image.rb

.read(input) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/informers/utils/image.rb', line 86

def self.read(input)
  if input.is_a?(RawImage)
    input
  elsif input.is_a?(URI)
    require "open-uri"

    RawImage.new(Vips::Image.new_from_buffer(input.read, ""))
  elsif input.is_a?(String)
    RawImage.new(Vips::Image.new_from_file(input))
  else
    raise ArgumentError, "Unsupported input type: #{input.class.name}"
  end
end