Class: IPTC::JPEG::Markers::APP0Marker

Inherits:
IPTC::JPEG::Marker show all
Defined in:
lib/iptc/jpeg/markers.rb

Overview

The APP0Marker

Contains some useful JFIF informations about the current image.

Instance Attribute Summary

Attributes inherited from IPTC::JPEG::Marker

#prefix, #values

Instance Method Summary collapse

Methods inherited from IPTC::JPEG::Marker

NewMarker, #l, #properties, #read, #to_binary

Constructor Details

#initialize(type, data) ⇒ APP0Marker

Returns a new instance of APP0Marker.



185
186
187
# File 'lib/iptc/jpeg/markers.rb', line 185

def initialize type, data 
  super type, data
end

Instance Method Details

#[](item) ⇒ Object



205
206
207
# File 'lib/iptc/jpeg/markers.rb', line 205

def [](item)
  return @values[item]
end

#parseObject



194
195
196
197
198
199
200
201
202
203
204
# File 'lib/iptc/jpeg/markers.rb', line 194

def parse

  @values = {
    'APP0/revision'=>read(2).unpack('n')[0],
    'APP0/unit' => read(1),
    'APP0/xdensity' => read(2).unpack('n')[0],
    'APP0/ydensity' => read(2).unpack('n')[0],
    'APP0/xthumbnail' => read(1).unpack('c')[0],
    'APP0/ythumbnail' => read(1).unpack('c')[0]
  }
end

#valid?Boolean

Returns:

  • (Boolean)


188
189
190
191
192
193
# File 'lib/iptc/jpeg/markers.rb', line 188

def valid?
  if read(5)!="JFIF\0"
    return false
  end
  return true
end