Class: ImageVoodoo::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/image_voodoo/metadata.rb

Overview

Metadata contained within the image.

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Metadata

Returns a new instance of Metadata.



7
8
9
# File 'lib/image_voodoo/metadata.rb', line 7

def initialize(io)
  @metadata = com.drew.imaging.ImageMetadataReader. io
end

Instance Method Details

#[](dirname) ⇒ Object

This will return a fairly useless Directory if you ask for one and there is no data in the image you are requesting. The reason for doing this is so queries like ‘md[:Orientation]’ can run and just return nil since I think this is the common case.

See Directory#exists? if you want to make sure the group you are requesting actually exists or not.

Raises:

  • (ArgumentError)


20
21
22
23
24
# File 'lib/image_voodoo/metadata.rb', line 20

def [](dirname)
  dirclass = DIRECTORY_MAP[dirname.to_s]
  raise ArgumentError, "Uknown metadata group: #{dirname}" unless dirclass
  dirclass.new @metadata
end

#heightObject

FIXME: I wonder if this needs to fall back to try all other directories for Image Height



42
43
44
# File 'lib/image_voodoo/metadata.rb', line 42

def height
  self['Exif Sub IFD']['Exif Image Height']
end

#makeObject

Common metadata methods exposed as convenience functions so users do not need to dig around in the various directories



28
29
30
# File 'lib/image_voodoo/metadata.rb', line 28

def make
  self[:IFD0][:Make]
end

#modelObject



32
33
34
# File 'lib/image_voodoo/metadata.rb', line 32

def model
  self[:IFD0][:Model]
end

#orientationObject



36
37
38
# File 'lib/image_voodoo/metadata.rb', line 36

def orientation
  self[:IFD0][:Orientation]
end

#widthObject



46
47
48
# File 'lib/image_voodoo/metadata.rb', line 46

def width
  self['Exif Sub IFD']['Exif Image Width']
end