Class: Cul::Image::Properties::Tiff
- Defined in:
- lib/cul_image_props/image/properties/types.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(srcfile = nil) ⇒ Tiff
constructor
A new instance of Tiff.
Methods inherited from Base
#[], #add_dt_prop, #extent=, #format=, #hex_inspect, #length=, #ord_value, #sampling_unit=, #width=, #x_sampling_freq=, #y_sampling_freq=
Constructor Details
#initialize(srcfile = nil) ⇒ Tiff
Returns a new instance of Tiff.
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/cul_image_props/image/properties/types.rb', line 305 def initialize(srcfile=nil) super header_bytes = @src.read(14) case header_bytes[0...4].unpack('C*') when Cul::Image::Magic::TIFF_INTEL_LE @endian = header_bytes[12] when Cul::Image::Magic::TIFF_MOTOROLA_BE @endian = header_bytes[12] else raise "Source file is not a tiff #{hex_inspect(header_bytes[0...4])}" end @src.rewind = Cul::Image::Properties::Exif.process_file(srcfile) if .include? 'Image ImageWidth' self.width= ['Image ImageWidth'].values[0] end if .include? 'Image ImageLength' self.length= ['Image ImageLength'].values[0] end if .include? 'Image XResolution' self.x_sampling_freq= ['Image XResolution'].values[0].inspect end if .include? 'Image YResolution' self.y_sampling_freq= ['Image YResolution'].values[0].inspect end if .include? 'Image ResolutionUnit' if (['Image ResolutionUnit'].values[0] == 3) self.sampling_unit=3 elsif (['Image ResolutionUnit'].values[0] == 2) self.sampling_unit=2 else self.sampling_unit=1 end end # do stuff with tags self.extent= srcfile.stat.size unless srcfile.nil? self.format=MIME[:tif] end |