photo-utils 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70d478e0579f15d1fdba607ac85c84827ba8cea2
4
- data.tar.gz: 53980404437217abd59062595727a0734aeb8fef
3
+ metadata.gz: 8258f2f73bf0c39dd9caad5983abe6692f27f602
4
+ data.tar.gz: cbf48be31fc7cf3c076d633ceda9cd27e09c69a5
5
5
  SHA512:
6
- metadata.gz: 94bc1d34be20f01ff721d12a681a5487d6278f17a50d9edddb0d1a1472f08195d532ce6d9d61b4d00cfd7e8c8579ea117c4a7c3af2c0bb91b653aed0dcad248e
7
- data.tar.gz: fc13ab1c3f0876db872371ee1bbf6082889333702faa349a6ed5f75e4c8474dee0cb9b4a3dd5d7b8e0d8135e4d5ef3382c51a4203085e0e91bd6bbccee5e0403
6
+ metadata.gz: 7b6671c81225c4140fc36947e8fa56ab85e4167e5e1b20a1ada4c09cb2c9f7cea00664dd72645098fc0a5005a06be66900372199bcd9d696c637fad0fe6bef5d
7
+ data.tar.gz: 36cd6bb50505fee27d5405df3c7243d20c6235b15a5bc2370108182eea7c30bb78eea93f9d1d00d19d56c23e02d0f0476ad58ee7a3cf1c569a8ec72d50f7b8b3
@@ -76,7 +76,7 @@ module PhotoUtils
76
76
  end
77
77
 
78
78
  def compensation=(n)
79
- @compensation = n ? Compensation.new_from_v(n) : nil
79
+ @compensation = Compensation.new(n)
80
80
  end
81
81
 
82
82
  def aperture
@@ -164,7 +164,7 @@ module PhotoUtils
164
164
  end
165
165
 
166
166
  def cv
167
- @compensation ? @compensation.to_f : 0
167
+ @compensation ? @compensation.to_v : 0
168
168
  end
169
169
 
170
170
  def ev
@@ -179,7 +179,7 @@ module PhotoUtils
179
179
  n = increment * (steps / 2)
180
180
  (-n..n).step(increment).map do |adjustment|
181
181
  new_exposure = dup
182
- new_exposure.compensation = (@compensation ? @compensation : 0) + adjustment
182
+ new_exposure.compensation = PhotoUtils::Compensation.new_from_v((@compensation ? @compensation.to_v : 0) + adjustment)
183
183
  new_exposure
184
184
  end
185
185
  end
@@ -18,7 +18,7 @@ module PhotoUtils
18
18
  end
19
19
 
20
20
  def to_v
21
- Math.log2(self.to_f / NK)
21
+ Math.log2(to_f / NK)
22
22
  end
23
23
 
24
24
  def to_cdm2
@@ -2,21 +2,40 @@ module PhotoUtils
2
2
 
3
3
  class Compensation < Value
4
4
 
5
- # amount specified in stops
5
+ # amount specified in factor
6
+
7
+ def self.new_from_factor(f)
8
+ new(f)
9
+ end
6
10
 
7
11
  def self.new_from_v(v)
8
- new(v)
12
+ new(2 ** v)
13
+ end
14
+
15
+ def to_factor
16
+ to_f
17
+ end
18
+
19
+ def to_v
20
+ Math.log2(to_f)
21
+ end
22
+
23
+ def format_factor
24
+ "x%.1f" % to_f.format(10)
9
25
  end
10
26
 
11
27
  def format_value
28
+ v = to_v
12
29
  "Cv:%s%s" % [
13
- (self < 0) ? '-' : '+',
14
- abs.format(10)
30
+ (v < 0) ? '-' : '+',
31
+ v.abs.format(10)
15
32
  ]
16
33
  end
17
34
 
18
- def to_s(format=:value)
35
+ def to_s(format=:factor)
19
36
  case format
37
+ when :factor
38
+ format_factor
20
39
  when :value
21
40
  format_value
22
41
  else
@@ -2,14 +2,21 @@ module PhotoUtils
2
2
 
3
3
  class Tool
4
4
 
5
+ def initialize
6
+ end
7
+
8
+ def name
9
+ self.class.to_s.downcase
10
+ end
11
+
5
12
  def usage
13
+ warn "#{$0} #{name} ..."
6
14
  end
7
15
 
8
16
  def description
9
17
  end
10
18
 
11
- def run(args)
12
- raise NotImplementedError, "Tool #{self.class} does not implement \#run"
19
+ def run
13
20
  end
14
21
 
15
22
  end
@@ -6,7 +6,7 @@ module PhotoUtils
6
6
 
7
7
  class Blur < Tool
8
8
 
9
- def run(args)
9
+ def run
10
10
  scene = Scene.new
11
11
  scene.sensitivity = 100
12
12
  scene.subject_distance = 6.feet
@@ -6,7 +6,7 @@ module PhotoUtils
6
6
 
7
7
  class Brightness < Tool
8
8
 
9
- def run(args)
9
+ def run
10
10
  scene = Scene.new
11
11
  scene.camera = Camera[/Rollei/]
12
12
  scene.description = "Salon L'Orient"
@@ -6,7 +6,7 @@ module PhotoUtils
6
6
 
7
7
  class CalcAperture < Tool
8
8
 
9
- def run(args)
9
+ def run
10
10
 
11
11
  # set up basic scene
12
12
 
@@ -6,7 +6,7 @@ module PhotoUtils
6
6
 
7
7
  class Cameras < Tool
8
8
 
9
- def run(args)
9
+ def run
10
10
  if Camera.cameras
11
11
  Camera.cameras.each do |camera|
12
12
  camera.print
@@ -6,7 +6,7 @@ module PhotoUtils
6
6
 
7
7
  class ChartDOF < Tool
8
8
 
9
- def run(args)
9
+ def run
10
10
 
11
11
  # set up basic scene
12
12
 
@@ -134,9 +134,8 @@ module PhotoUtils
134
134
  end
135
135
  end
136
136
 
137
- raise "Usage: #{$0} output-file.html" unless ARGV.first
138
- File.open(ARGV.first, 'w') { |f| f.write(html.target!) }
139
-
137
+ output_file = @args.first or raise
138
+ Path.new(output_file).write(html.target!)
140
139
  end
141
140
 
142
141
  end
@@ -9,7 +9,7 @@ module PhotoUtils
9
9
 
10
10
  class Compare < Tool
11
11
 
12
- def run(args)
12
+ def run
13
13
  # given:
14
14
  # an image file with EXIF data
15
15
  # extract:
@@ -6,7 +6,7 @@ module PhotoUtils
6
6
 
7
7
  class DOF < Tool
8
8
 
9
- def run(args)
9
+ def run
10
10
 
11
11
  cameras = []
12
12
  cameras << Camera[/Bronica/]
@@ -6,7 +6,7 @@ module PhotoUtils
6
6
 
7
7
  class DOFTable < Tool
8
8
 
9
- def run(args)
9
+ def run
10
10
  scene = Scene.new
11
11
  scene.camera = Camera[/Eastman/]
12
12
 
@@ -14,7 +14,7 @@ module PhotoUtils
14
14
  scene.print_camera
15
15
  puts
16
16
 
17
- # Av equivalents of f/4 -- f/64
17
+ # Av equivalents of f/4 ~ f/64
18
18
  apertures = (4..12).map { |av| Aperture.new_from_v(av) }
19
19
 
20
20
  first = true
@@ -6,7 +6,7 @@ module PhotoUtils
6
6
 
7
7
  class FilmTest < Tool
8
8
 
9
- def run(args)
9
+ def run
10
10
  camera = Camera['Hasselblad']
11
11
 
12
12
  scene = Scene.new
@@ -6,11 +6,11 @@ module PhotoUtils
6
6
 
7
7
  class FocalLength < Tool
8
8
 
9
- def run(args)
10
- from_focal_length, from_format = args.shift.split(':')
9
+ def run
10
+ from_focal_length, from_format = @args.shift.split(':')
11
11
  from_focal_length = from_focal_length.to_i
12
12
  from_format = (Format[from_format || '35'] or raise "Unknown format: #{from_format.inspect}")
13
- to_formats = args.first ? args.shift.split(',') : %w{1/1.7 APS-C APS-H 35 6x4.5 6x6 6x7 5x7}
13
+ to_formats = @args.first ? @args.shift.split(',') : %w{1/1.7 APS-C APS-H 35 6x4.5 6x6 6x7 5x7}
14
14
  to_formats.map { |f| Format[f] or raise "Unknown format: #{f.inspect}" }.each do |to_format|
15
15
  scene = Scene.new
16
16
  scene.format = from_format
@@ -14,9 +14,9 @@ module PhotoUtils
14
14
  }
15
15
  end
16
16
 
17
- def run(args)
18
- if args.first
19
- r = args.shift.split('-', 2).map { |n| n ? n.to_i : nil }
17
+ def run
18
+ if @args.first
19
+ r = @args.first.split('-', 2).map { |n| n ? n.to_i : nil }
20
20
  else
21
21
  r = 1..100
22
22
  end
@@ -6,7 +6,7 @@ module PhotoUtils
6
6
 
7
7
  class Test < Tool
8
8
 
9
- def run(args)
9
+ def run
10
10
 
11
11
  # field_of_view = Frame.new(5.feet, 8.feet)
12
12
  subject_distance = 3.feet
@@ -1,5 +1,5 @@
1
1
  module PhotoUtils
2
2
 
3
- VERSION = '0.2'
3
+ VERSION = '0.3'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photo-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Labovitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2016-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashstruct
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  version: '0'
171
171
  requirements: []
172
172
  rubyforge_project:
173
- rubygems_version: 2.5.0
173
+ rubygems_version: 2.5.1
174
174
  signing_key:
175
175
  specification_version: 4
176
176
  summary: Models, formulas, and utilties for photography optics, etc.
@@ -182,4 +182,3 @@ test_files:
182
182
  - test/scene_test.rb
183
183
  - test/sensitivity_test.rb
184
184
  - test/time_test.rb
185
- has_rdoc: