How can I access the EXIF compression details? It's returning nil even being present inside my exif hash.
ruby-1.9.2-p290 :012 > require 'exifr'
ruby-1.9.2-p290 :015 > EXIFR::JPEG.new('/Users/lb/Desktop/lol.jpg')
(...), @exif=[{:make=>"Canon", :model=>"Canon EOS 5D Mark II", :x_resolution=>(240/1), :y_resolution=>(240/1), :resolution_unit=>2, :software=>"Adobe Photoshop Lightroom 3.4.1", :date_time=>2011-08-09 17:19:52 +0100, :exposure_time=>(1/30), :f_number=>(14/5), :exposure_program=>3, :iso_speed_ratings=&g开发者_高级运维t;3200, :date_time_original=>2011-07-30 12:34:45 +0100, :date_time_digitized=>2011-07-30 12:34:45 +0100, :shutter_speed_value=>(4906891/1000000), :aperture_value=>(1485427/500000), :exposure_bias_value=>(0/1), :max_aperture_value=>(3/1), :subject_distance=>(4294967295/1), :metering_mode=>3, :flash=>16, :focal_length=>(35/1), :subsec_time_orginal=>"35", :subsec_time_digitized=>"35", :focal_plane_x_resolution=>(5616000/1459), :focal_plane_y_resolution=>(1872000/479), :focal_plane_resolution_unit=>2, :custom_rendered=>0, :exposure_mode=>0, :white_balance=>1, :scene_capture_type=>0}, {:compression=>6, :x_resolution=>(72/1), :y_resolution=>(72/1), :resolution_unit=>2, :jpeg_interchange_format=>818, :jpeg_interchange_format_length=>13241}]>
ruby-1.9.2-p290 :011 > EXIFR::JPEG.new('/Users/lb/Desktop/lol.jpg').white_balance
=> 1
ruby-1.9.2-p290 :012 > EXIFR::JPEG.new('/Users/lb/Desktop/lol.jpg').compression
=> nil (I was expecting 6)
Thanks
Try this:
EXIFR::JPEG.new(...).exif.compression
Or:
EXIFR::JPEG.new(...).exif.collect { |e| e.compression }.flatten.first
Or more compact:
EXIFR::JPEG.new(...).exif.map(&:compression).flatten.first
精彩评论