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, ".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

#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["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_atObject



39
40
41
# File 'lib/pano/image_file.rb', line 39

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 && bracketed?
end

#list_infoObject



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