Class: ImageRuby::Decoder

Inherits:
Object show all
Defined in:
lib/imageruby/decoder.rb

Defined Under Namespace

Classes: UnableToDecodeException

Class Method Summary collapse

Class Method Details

.decode(data, image_class) ⇒ Object

Decodes an image from raw binary data (String), raises UnableToDecodeException if the format of the encoded data is unknown

To load a image from disk use Image.from_file(path) method



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/imageruby/decoder.rb', line 36

def self.decode(data, image_class)
  Decoder.each_subclass do |sc|
    decoder = sc.new

    begin
      return decoder.decode(data, image_class)
    rescue UnableToDecodeException

    end
  end

  raise UnableToDecodeException
end