Class: Pano::ImageFile

Inherits:
Object
  • Object
show all
Includes:
Image
Defined in:
lib/pano/image_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Image

#read_info

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

#infoObject (readonly)

Returns the value of attribute info.



5
6
7
# File 'lib/pano/image_file.rb', line 5

def info
  @info
end

#jpg_pathObject (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_pathObject (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

Returns:

  • (Boolean)


29
30
31
# File 'lib/pano/image_file.rb', line 29

def bracketed?
  @bracketed ||= @info["BracketMode"] == "AEB" && @info["BracketShotNumber"] == 0
end

#bracketing_numberObject



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_atObject



44
45
46
# File 'lib/pano/image_file.rb', line 44

def created_at
  @created_at ||= @info[:created_at]
end

#for_pano?Boolean

Returns:

  • (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_infoObject



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