Class: Exiv2::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/exiv2/image.rb

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object

method [] is used to read exif or iptc data



4
5
6
7
# File 'lib/exiv2/image.rb', line 4

def [](key)
  return exif[key] if key[0...4] == "Exif"
  return iptc[key] if key[0...4] == "Iptc"
end

#[]=(key, value) ⇒ Object

method []= is used to set exif or iptc data

Raises:



10
11
12
13
14
# File 'lib/exiv2/image.rb', line 10

def []=(key, value)
  return exif[key] = value if key[0...4] == "Exif"
  return iptc[key] = value if key[0...4] == "Iptc"
  raise Exiv2::Error, "Unknown key for writing: #{key.inspect}"
end

#created_atObject

clues together Iptc.Application2.DateCreated and Iptc.Application2.TimeCreated if possible



17
18
19
20
21
22
# File 'lib/exiv2/image.rb', line 17

def created_at
  date = iptc["Iptc.Application2.DateCreated"]
  time = iptc["Iptc.Application2.TimeCreated"]
  return date unless time
  Time.utc(date.year, date.month, date.day, time.hour, time.min, time.sec)
end