Class: Exif::Parser
- Inherits:
-
Object
- Object
- Exif::Parser
- Defined in:
- lib/exifparser.rb,
lib/exifparser/thumbnail.rb
Instance Method Summary collapse
-
#[](tagname) ⇒ Object
search the specified tag values.
-
#[]=(tag, value) ⇒ Object
set the specified tag to the specified value.
-
#each(ifd = nil) ⇒ Object
execute given block with block argument being every tags defined in all the IFDs contained in the image.
- #init_from_scanner ⇒ Object
-
#initialize(file_handler) ⇒ Parser
constructor
create a new object.
- #inspect ⇒ Object
- #marshal_dump ⇒ Object
- #marshal_load(marshaled) ⇒ Object
-
#orig_thumbnail ⇒ Object
extract the thumbnail image to dest.
- #prepare_file(handler) ⇒ Object
-
#tag(tagname, ifd = nil) ⇒ Object
search tag on the specific IFD.
-
#tag?(tagid) ⇒ Boolean
return true if specified tagid is defined or has some value.
-
#tags(ifd = nil) ⇒ Object
return all the tags in the image.
-
#thumbnail ⇒ Object
redefine method.
-
#thumbnail_size ⇒ Object
return the size of the thumbnail image.
Constructor Details
Instance Method Details
#[](tagname) ⇒ Object
search the specified tag values. return value is object of classes defined under Exif::Tag module.
150 151 152 |
# File 'lib/exifparser.rb', line 150 def [](tagname) self.tag(tagname) end |
#[]=(tag, value) ⇒ Object
set the specified tag to the specified value. XXX NOT IMPLEMETED XXX
158 159 160 |
# File 'lib/exifparser.rb', line 158 def []=(tag, value) # not implemented end |
#each(ifd = nil) ⇒ Object
execute given block with block argument being every tags defined in all the IFDs contained in the image.
if argument ifd is specified, every tags defined in the specified IFD are passed to block.
return value is object of classes defined under Exif::Tag module.
allowable arguments are:
-
:IFD0
-
:IFD1
-
:Exif
-
:GPS
-
:Interoperability
-
:MakerNote
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/exifparser.rb', line 223 def each(ifd=nil) if ifd @scanner.result[ifd].each{ |tag| yield tag } else [ @IFD0, @IFD1, @Exif, @GPS, @Interoperability, @MakerNote ].flatten.each do |tag| yield tag end end end |
#init_from_scanner ⇒ Object
108 109 110 111 112 113 114 115 116 |
# File 'lib/exifparser.rb', line 108 def init_from_scanner @IFD0 = @scanner.result[:IFD0] @IFD1 = @scanner.result[:IFD1] @Exif = @scanner.result[:Exif] @GPS = @scanner.result[:GPS] @Interoperability = @scanner.result[:Interoperability] @MakerNote = @scanner.result[:MakerNote] @thumbnail = @scanner.result[:Thumbnail] end |
#inspect ⇒ Object
128 129 130 |
# File 'lib/exifparser.rb', line 128 def inspect sprintf("#<%s filename=\"%s\" entries: IFD0(%d) IFD1(%d) Exif(%d) GPS(%d) Interoperability(%d) MakerNote(%d)>", self.class, @fpath, @IFD0.length, @IFD1.length, @Exif.length, @GPS.length, @Interoperability.length, @MakerNote.length) end |
#marshal_dump ⇒ Object
240 241 242 |
# File 'lib/exifparser.rb', line 240 def marshal_dump {scanner: Marshal.dump(@scanner)} end |
#marshal_load(marshaled) ⇒ Object
244 245 246 247 |
# File 'lib/exifparser.rb', line 244 def marshal_load marshaled @scanner = Marshal.load marshaled[:scanner] init_from_scanner end |
#orig_thumbnail ⇒ Object
extract the thumbnail image to dest. dest should respond to ‘<<’ method.
14 15 16 |
# File 'lib/exifparser/thumbnail.rb', line 14 def thumbnail(dest) dest << @thumbnail end |
#prepare_file(handler) ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'lib/exifparser.rb', line 118 def prepare_file(handler) if handler.is_a? String @fpath = handler File.open(handler, "rb") elsif handler.is_a?(StringIO) || handler.is_a?(File) @fpath = 'dummy_file' handler end end |
#tag(tagname, ifd = nil) ⇒ Object
search tag on the specific IFD
142 143 144 |
# File 'lib/exifparser.rb', line 142 def tag(tagname, ifd=nil) search_tag(tagname, ifd) end |
#tag?(tagid) ⇒ Boolean
return true if specified tagid is defined or has some value.
135 136 137 |
# File 'lib/exifparser.rb', line 135 def tag?(tagid) search_tag(tagid) ? true : false end |
#tags(ifd = nil) ⇒ Object
return all the tags in the image.
if argument ifd is specified, every tags defined in the specified IFD are passed to block.
return value is object of classes defined under Exif::Tag module.
allowable arguments are:
-
:IFD0
-
:IFD1
-
:Exif
-
:GPS
-
:Interoperability
-
:MakerNote (if exist)
192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/exifparser.rb', line 192 def (ifd=nil) if ifd @scanner.result[ifd] else [ @IFD0, @IFD1, @Exif, @GPS, @Interoperability, @MakerNote ].flatten end end |
#thumbnail ⇒ Object
redefine method.
166 167 168 |
# File 'lib/exifparser.rb', line 166 def thumbnail(dest) dest << @thumbnail end |
#thumbnail_size ⇒ Object
return the size of the thumbnail image
173 174 175 |
# File 'lib/exifparser.rb', line 173 def thumbnail_size @thumbnail.size end |