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
- #bracketing_number ⇒ Object
- #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, ".CR2") else @raw_path = path @jpg_path = path.sub(/\.cr2$/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["BracketMode"] == "AEB" && @info["BracketShotNumber"] == 0 end |
#bracketing_number ⇒ Object
33 34 35 36 |
# File 'lib/pano/image_file.rb', line 33 def bracketing_number b = @info["BracketValue"] b == 0 ? 0 : b < 0 ? 1 : 2 end |
#copy_to(dest_dir) ⇒ Object
48 49 50 51 52 |
# File 'lib/pano/image_file.rb', line 48 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
44 45 46 |
# File 'lib/pano/image_file.rb', line 44 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 && @info["SelfTimer"] == "2 s" && @info["Orientation"] == "Rotate 270 CW" end |
#list_info ⇒ Object
38 39 40 41 42 |
# File 'lib/pano/image_file.rb', line 38 def list_info @info.each_pair do |k, v| puts "#{k} - #{v}" end end |