Class: Cul::Image::Properties::Gif

Inherits:
Base
  • Object
show all
Defined in:
lib/cul_image_props/image/properties/types.rb

Constant Summary

Constants inherited from Base

Base::BASE_XML

Instance Attribute Summary

Attributes inherited from Base

#nodeset

Instance Method Summary collapse

Methods inherited from Base

#[], #add_dt_prop, #extent=, #format=, #hex_inspect, #length=, #ord_value, #sampling_unit=, #width=, #x_sampling_freq=, #y_sampling_freq=

Constructor Details

#initialize(srcfile = nil) ⇒ Gif

Returns a new instance of Gif.



127
128
129
130
131
132
133
134
135
136
137
# File 'lib/cul_image_props/image/properties/types.rb', line 127

def initialize(srcfile=nil)
  super
  header_bytes = @src.read(13)
  unless header_bytes[0...4].unpack('C*') == Cul::Image::Magic::GIF
    raise "Source file is not a gif: #{hex_inspect(header_bytes[0...4])}"
  end
  self.width= header_bytes[6,2].unpack('v')[0]
  self.length= header_bytes[8,2].unpack('v')[0]
  self.extent= srcfile.stat.size unless srcfile.nil?
  self.format= MIME[:gif]
end