Class: ImageSpec::Parser::PNG
- Inherits:
-
Object
- Object
- ImageSpec::Parser::PNG
- Defined in:
- lib/parser/png.rb
Constant Summary collapse
- CONTENT_TYPE =
'image/png'
Class Method Summary collapse
Class Method Details
.attributes(stream) ⇒ Object
8 9 10 11 |
# File 'lib/parser/png.rb', line 8 def self.attributes(stream) width, height = dimensions(stream) {:width => width, :height => height, :content_type => CONTENT_TYPE} end |
.detected?(stream) ⇒ Boolean
13 14 15 16 |
# File 'lib/parser/png.rb', line 13 def self.detected?(stream) stream.rewind stream.read(4) == "\x89PNG" end |
.dimensions(stream) ⇒ Object
18 19 20 21 |
# File 'lib/parser/png.rb', line 18 def self.dimensions(stream) stream.seek(0x10) stream.read(8).unpack('NN') end |