Class: ImageVoodoo::Metadata
- Inherits:
-
Object
- Object
- ImageVoodoo::Metadata
- Defined in:
- lib/image_voodoo/metadata.rb
Overview
Metadata contained within the image.
Instance Method Summary collapse
-
#[](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.
-
#height ⇒ Object
FIXME: I wonder if this needs to fall back to try all other directories for Image Height.
-
#initialize(io) ⇒ Metadata
constructor
A new instance of Metadata.
-
#make ⇒ Object
Common metadata methods exposed as convenience functions so users do not need to dig around in the various directories.
- #model ⇒ Object
- #orientation ⇒ Object
- #to_s ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(io) ⇒ Metadata
Returns a new instance of Metadata.
9 10 11 |
# File 'lib/image_voodoo/metadata.rb', line 9 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.
22 23 24 25 26 27 28 |
# File 'lib/image_voodoo/metadata.rb', line 22 def [](dirname) dirclass = DIRECTORY_MAP[dirname.to_s] raise ArgumentError, "Uknown metadata group: #{dirname}" unless dirclass dirclass.new @metadata end |
#height ⇒ Object
FIXME: I wonder if this needs to fall back to try all other directories for Image Height
46 47 48 |
# File 'lib/image_voodoo/metadata.rb', line 46 def height self['Exif Sub IFD']['Exif Image Height'] end |
#make ⇒ Object
Common metadata methods exposed as convenience functions so users do not need to dig around in the various directories
32 33 34 |
# File 'lib/image_voodoo/metadata.rb', line 32 def make self[:IFD0][:Make] end |
#model ⇒ Object
36 37 38 |
# File 'lib/image_voodoo/metadata.rb', line 36 def model self[:IFD0][:Model] end |
#orientation ⇒ Object
40 41 42 |
# File 'lib/image_voodoo/metadata.rb', line 40 def orientation self[:IFD0][:Orientation] end |
#to_s ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/image_voodoo/metadata.rb', line 54 def to_s out = StringIO.new out.puts "[{dir name}] - {tag name} = {tag descr}" out.puts "---------------------------------------" @metadata.directories.each do |directory| directory..each do |tag| out.puts "[#{directory.name}] - #{tag.tag_name} = #{tag.description}" end end out.string end |
#width ⇒ Object
50 51 52 |
# File 'lib/image_voodoo/metadata.rb', line 50 def width self['Exif Sub IFD']['Exif Image Width'] end |