Class: Pano::ImageFile
Instance Attribute Summary collapse
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#jpg_path ⇒ Object
readonly
Returns the value of attribute jpg_path.
-
#raw_path ⇒ Object
readonly
Returns the value of attribute raw_path.
Instance Method Summary collapse
- #bracketed? ⇒ Boolean
- #copy_to(dest_dir) ⇒ Object
- #created_at ⇒ Object
- #for_pano? ⇒ Boolean
-
#initialize(path) ⇒ ImageFile
constructor
A new instance of ImageFile.
- #list_info ⇒ Object
Methods included from Image
Constructor Details
#initialize(path) ⇒ ImageFile
Returns a new instance of ImageFile.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pano/image_file.rb', line 7 def initialize path if path =~ /\.jpg$/i @jpg_path = path @raw_path = path.sub(/\.jpg$/i, ".NEF") else @raw_path = path @jpg_path = path.sub(/\.nef$/i, ".JPG") end if File.exist?(@jpg_path) @info = read_info(@jpg_path) elsif File.exist?(raw_path) @info = read_info(@raw_path) else raise "File not found '#{path}'" end end |
Instance Attribute Details
#info ⇒ Object (readonly)
Returns the value of attribute info.
5 6 7 |
# File 'lib/pano/image_file.rb', line 5 def info @info end |
#jpg_path ⇒ Object (readonly)
Returns the value of attribute jpg_path.
5 6 7 |
# File 'lib/pano/image_file.rb', line 5 def jpg_path @jpg_path end |
#raw_path ⇒ Object (readonly)
Returns the value of attribute raw_path.
5 6 7 |
# File 'lib/pano/image_file.rb', line 5 def raw_path @raw_path end |
Instance Method Details
#bracketed? ⇒ Boolean
29 30 31 |
# File 'lib/pano/image_file.rb', line 29 def bracketed? @bracketed ||= @info["ShootingMode"] =~ /Bracketing/i end |
#copy_to(dest_dir) ⇒ Object
43 44 45 46 47 |
# File 'lib/pano/image_file.rb', line 43 def copy_to dest_dir FileUtils.mkpath dest_dir FileUtils.cp(@raw_path, dest_dir) if File.exist?(@raw_path) FileUtils.cp(@jpg_path, dest_dir) if File.exist?(@jpg_path) end |
#created_at ⇒ Object
39 40 41 |
# File 'lib/pano/image_file.rb', line 39 def created_at @created_at ||= @info[:created_at] end |
#for_pano? ⇒ Boolean
25 26 27 |
# File 'lib/pano/image_file.rb', line 25 def for_pano? @for_pano ||= @info[:fov] > 95 && bracketed? end |
#list_info ⇒ Object
33 34 35 36 37 |
# File 'lib/pano/image_file.rb', line 33 def list_info @info.each_pair do |k, v| puts "#{k} - #{v}" end end |