qttk 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/Gemfile +6 -0
  4. data/Gemfile.lock +36 -0
  5. data/README.markdown +131 -0
  6. data/Rakefile +17 -0
  7. data/TODO.markdown +236 -0
  8. data/bin/qt +7 -0
  9. data/etc/gutenprint/gp-tool.rb +56 -0
  10. data/etc/gutenprint/gutenprint-filter.c +400 -0
  11. data/etc/gutenprint/gutenprint.rb +86 -0
  12. data/etc/gutenprint/stp-test +326 -0
  13. data/etc/images/3551599565_db282cf840_o.jpg +0 -0
  14. data/etc/images/4843122063_d582c569e9_o.jpg +0 -0
  15. data/etc/images/4843128953_83c1770907_o.jpg +0 -0
  16. data/lib/quadtone.rb +56 -0
  17. data/lib/quadtone/cgats.rb +137 -0
  18. data/lib/quadtone/cluster_calculator.rb +81 -0
  19. data/lib/quadtone/color.rb +83 -0
  20. data/lib/quadtone/color/cmyk.rb +112 -0
  21. data/lib/quadtone/color/device_n.rb +23 -0
  22. data/lib/quadtone/color/gray.rb +46 -0
  23. data/lib/quadtone/color/lab.rb +150 -0
  24. data/lib/quadtone/color/qtr.rb +71 -0
  25. data/lib/quadtone/color/rgb.rb +71 -0
  26. data/lib/quadtone/color/xyz.rb +80 -0
  27. data/lib/quadtone/curve.rb +138 -0
  28. data/lib/quadtone/curve_set.rb +196 -0
  29. data/lib/quadtone/descendants.rb +9 -0
  30. data/lib/quadtone/environment.rb +5 -0
  31. data/lib/quadtone/extensions/math.rb +11 -0
  32. data/lib/quadtone/extensions/pathname3.rb +11 -0
  33. data/lib/quadtone/printer.rb +106 -0
  34. data/lib/quadtone/profile.rb +217 -0
  35. data/lib/quadtone/quad_file.rb +59 -0
  36. data/lib/quadtone/renderer.rb +139 -0
  37. data/lib/quadtone/run.rb +10 -0
  38. data/lib/quadtone/sample.rb +32 -0
  39. data/lib/quadtone/separator.rb +36 -0
  40. data/lib/quadtone/target.rb +277 -0
  41. data/lib/quadtone/tool.rb +61 -0
  42. data/lib/quadtone/tools/add_printer.rb +73 -0
  43. data/lib/quadtone/tools/characterize.rb +43 -0
  44. data/lib/quadtone/tools/chart.rb +31 -0
  45. data/lib/quadtone/tools/check.rb +16 -0
  46. data/lib/quadtone/tools/dir.rb +15 -0
  47. data/lib/quadtone/tools/edit.rb +23 -0
  48. data/lib/quadtone/tools/init.rb +82 -0
  49. data/lib/quadtone/tools/install.rb +15 -0
  50. data/lib/quadtone/tools/linearize.rb +28 -0
  51. data/lib/quadtone/tools/list.rb +19 -0
  52. data/lib/quadtone/tools/print.rb +38 -0
  53. data/lib/quadtone/tools/printer_options.rb +40 -0
  54. data/lib/quadtone/tools/rename.rb +17 -0
  55. data/lib/quadtone/tools/render.rb +43 -0
  56. data/lib/quadtone/tools/rewrite.rb +15 -0
  57. data/lib/quadtone/tools/separate.rb +71 -0
  58. data/lib/quadtone/tools/show.rb +15 -0
  59. data/lib/quadtone/tools/test.rb +26 -0
  60. data/qttk.gemspec +34 -0
  61. metadata +215 -0
@@ -0,0 +1,40 @@
1
+ module Quadtone
2
+
3
+ module Tools
4
+
5
+ class PrinterOptions < Tool
6
+
7
+ attr_accessor :printer
8
+ attr_accessor :show_attributes
9
+
10
+ def load_profile
11
+ false
12
+ end
13
+
14
+ def parse_option(option, args)
15
+ case option
16
+ when '--printer'
17
+ @printer = Printer.new(args.shift)
18
+ when '--show-attributes'
19
+ @show_attributes = true
20
+ end
21
+ end
22
+
23
+ def run(*args)
24
+ if @printer
25
+ printer = @printer
26
+ elsif @profile
27
+ printer = @profile.printer
28
+ else
29
+ raise ToolUsageError, "Must specify either printer or profile"
30
+ end
31
+ printer.show_attributes if @show_attributes
32
+ printer.show_options
33
+ printer.show_inks
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,17 @@
1
+ module Quadtone
2
+
3
+ module Tools
4
+
5
+ class Rename < Tool
6
+
7
+ def run(*args)
8
+ new_name = args.shift or raise "Must specify new name"
9
+ new_path = Profile::ProfilesDir + new_name
10
+ @profile.dir_path.rename(new_path)
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,43 @@
1
+ module Quadtone
2
+
3
+ module Tools
4
+
5
+ class Render < Tool
6
+
7
+ attr_accessor :rotate
8
+ attr_accessor :resolution
9
+ attr_accessor :page_size
10
+ attr_accessor :desired_size
11
+
12
+ def parse_option(option, args)
13
+ case option
14
+ when '--rotate'
15
+ @rotate = true
16
+ when '--resolution'
17
+ @resolution = args.shift.to_f
18
+ when '--page-size'
19
+ @page_size = @profile.printer.page_size(args.shift)
20
+ when '--desired-size'
21
+ width, height = args.shift.split('x').map(&:to_f)
22
+ @desired_size = HashStruct.new(width: width, height: height)
23
+ end
24
+ end
25
+
26
+ def run(*args)
27
+ options = {}
28
+ options.merge!(rotate: @rotate) if @rotate
29
+ options.merge!(resolution: @resolution) if @resolution
30
+ options.merge!(page_size: @page_size) if @page_size
31
+ options.merge!(desired_size: @desired_size) if @desired_size
32
+ renderer = Renderer.new(options)
33
+ args.map { |p| Pathname.new(p) }.each do |input_path|
34
+ output_paths = renderer.render(input_path)
35
+ ;;warn "\t" + "Wrote rendered file to #{output_paths.join(', ')}"
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,15 @@
1
+ module Quadtone
2
+
3
+ module Tools
4
+
5
+ class Rewrite < Tool
6
+
7
+ def run
8
+ @profile.save
9
+ end
10
+
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,71 @@
1
+ module Quadtone
2
+
3
+ module Tools
4
+
5
+ class Separate < Tool
6
+
7
+ attr_accessor :montage
8
+ attr_accessor :gradient
9
+ attr_accessor :save_luts
10
+
11
+ def parse_option(option, args)
12
+ case option
13
+ when '--montage'
14
+ @montage = true
15
+ when '--gradient'
16
+ @gradient = true
17
+ when '--save-luts'
18
+ @save_luts = true
19
+ end
20
+ end
21
+
22
+ def run(image_file=nil)
23
+
24
+ if @gradient
25
+ image_file = Pathname.new('gradient.tif')
26
+ image = Magick::Image.new(200, 200, Magick::GradientFill.new(0, 0, 0, 200, 'white', 'black'))
27
+ else
28
+ raise ToolUsageError, "Must specify image file (or --gradient option)" unless image_file
29
+ image_file = Pathname.new(image_file)
30
+ image = Magick::Image.read(image_file).first
31
+ end
32
+
33
+ quad = QuadFile.new(@profile)
34
+ separator = Separator.new(quad.curve_set)
35
+ images = separator.separate(image)
36
+
37
+ if @montage
38
+ image_list = Magick::ImageList.new
39
+ image_copy = image.copy
40
+ image_copy['Label'] = 'original'
41
+ image_list << image_copy
42
+ image_list += images.values
43
+ separated_image = image_list.montage do
44
+ self.frame = '2x2'
45
+ self.geometry = '300x300'
46
+ end
47
+ separated_image_file = image_file.with_extname(".#{@profile.name}.sep.tif")
48
+ ;;warn "writing montaged separated file to #{separated_image_file}"
49
+ separated_image.write(separated_image_file) { self.compression = Magick::ZipCompression }
50
+ else
51
+ images.each do |channel, separated_image|
52
+ separated_image_file = image_file.with_extname(".#{@profile.name}.sep-#{channel}.tif")
53
+ ;;warn "writing channel #{channel} of separated file to #{separated_image_file}"
54
+ separated_image.write(separated_image_file) { self.compression = Magick::ZipCompression }
55
+ end
56
+ end
57
+
58
+ if @save_luts
59
+ separator.luts.each do |channel, lut_image|
60
+ lut_file = image_file.with_extname(".#{@profile.name}.lut-#{channel}.tif")
61
+ ;;warn "writing LUT image to #{lut_file}"
62
+ lut_image.write(lut_file) { self.compression = Magick::ZipCompression }
63
+ end
64
+ end
65
+ end
66
+
67
+ end
68
+
69
+ end
70
+
71
+ end
@@ -0,0 +1,15 @@
1
+ module Quadtone
2
+
3
+ module Tools
4
+
5
+ class Show < Tool
6
+
7
+ def run
8
+ @profile.show
9
+ end
10
+
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,26 @@
1
+ module Quadtone
2
+
3
+ module Tools
4
+
5
+ class Test < Tool
6
+
7
+ def run(*args)
8
+ case (action = args.shift)
9
+ when 'build'
10
+ @profile.test_curveset.build_target
11
+ when 'print'
12
+ @profile.test_curveset.print_target
13
+ when 'measure'
14
+ @profile.test_curveset.measure_target
15
+ when 'process'
16
+ @profile.test_curveset.process_target
17
+ else
18
+ raise ToolUsageError, "Unknown action: #{action.inspect}"
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ $LOAD_PATH << File.expand_path('../lib', __FILE__)
4
+
5
+ # require 'qttk/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'qttk'
9
+ s.version = '0.1.0' # QTTK::VERSION
10
+ s.author = 'John Labovitz'
11
+ s.email = 'johnl@johnlabovitz.com'
12
+ s.homepage = 'http://github.com/jslabovitz/qttk'
13
+ s.summary = %q{Tools for working with the quadtone printing process}
14
+ s.description = %q{
15
+ Quadtone Toolkit (QTTK): Tools for working with the quadtone printing process.
16
+ }
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ['lib']
22
+
23
+ s.add_dependency 'builder'
24
+ s.add_dependency 'pathname3'
25
+ s.add_dependency 'rmagick'
26
+ s.add_dependency 'ffi'
27
+ s.add_dependency 'cupsffi'
28
+ s.add_dependency 'hashstruct'
29
+ s.add_dependency 'descriptive_statistics'
30
+ s.add_dependency 'spliner'
31
+
32
+ # s.add_development_dependency 'minitest'
33
+ # s.add_development_dependency 'wrong'
34
+ end
metadata ADDED
@@ -0,0 +1,215 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qttk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - John Labovitz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: builder
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pathname3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rmagick
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ffi
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: cupsffi
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: hashstruct
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: descriptive_statistics
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: spliner
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: "\n Quadtone Toolkit (QTTK): Tools for working with the quadtone printing
126
+ process.\n "
127
+ email: johnl@johnlabovitz.com
128
+ executables:
129
+ - qt
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - Gemfile
135
+ - Gemfile.lock
136
+ - README.markdown
137
+ - Rakefile
138
+ - TODO.markdown
139
+ - bin/qt
140
+ - etc/gutenprint/gp-tool.rb
141
+ - etc/gutenprint/gutenprint-filter.c
142
+ - etc/gutenprint/gutenprint.rb
143
+ - etc/gutenprint/stp-test
144
+ - etc/images/3551599565_db282cf840_o.jpg
145
+ - etc/images/4843122063_d582c569e9_o.jpg
146
+ - etc/images/4843128953_83c1770907_o.jpg
147
+ - lib/quadtone.rb
148
+ - lib/quadtone/cgats.rb
149
+ - lib/quadtone/cluster_calculator.rb
150
+ - lib/quadtone/color.rb
151
+ - lib/quadtone/color/cmyk.rb
152
+ - lib/quadtone/color/device_n.rb
153
+ - lib/quadtone/color/gray.rb
154
+ - lib/quadtone/color/lab.rb
155
+ - lib/quadtone/color/qtr.rb
156
+ - lib/quadtone/color/rgb.rb
157
+ - lib/quadtone/color/xyz.rb
158
+ - lib/quadtone/curve.rb
159
+ - lib/quadtone/curve_set.rb
160
+ - lib/quadtone/descendants.rb
161
+ - lib/quadtone/environment.rb
162
+ - lib/quadtone/extensions/math.rb
163
+ - lib/quadtone/extensions/pathname3.rb
164
+ - lib/quadtone/printer.rb
165
+ - lib/quadtone/profile.rb
166
+ - lib/quadtone/quad_file.rb
167
+ - lib/quadtone/renderer.rb
168
+ - lib/quadtone/run.rb
169
+ - lib/quadtone/sample.rb
170
+ - lib/quadtone/separator.rb
171
+ - lib/quadtone/target.rb
172
+ - lib/quadtone/tool.rb
173
+ - lib/quadtone/tools/add_printer.rb
174
+ - lib/quadtone/tools/characterize.rb
175
+ - lib/quadtone/tools/chart.rb
176
+ - lib/quadtone/tools/check.rb
177
+ - lib/quadtone/tools/dir.rb
178
+ - lib/quadtone/tools/edit.rb
179
+ - lib/quadtone/tools/init.rb
180
+ - lib/quadtone/tools/install.rb
181
+ - lib/quadtone/tools/linearize.rb
182
+ - lib/quadtone/tools/list.rb
183
+ - lib/quadtone/tools/print.rb
184
+ - lib/quadtone/tools/printer_options.rb
185
+ - lib/quadtone/tools/rename.rb
186
+ - lib/quadtone/tools/render.rb
187
+ - lib/quadtone/tools/rewrite.rb
188
+ - lib/quadtone/tools/separate.rb
189
+ - lib/quadtone/tools/show.rb
190
+ - lib/quadtone/tools/test.rb
191
+ - qttk.gemspec
192
+ homepage: http://github.com/jslabovitz/qttk
193
+ licenses: []
194
+ metadata: {}
195
+ post_install_message:
196
+ rdoc_options: []
197
+ require_paths:
198
+ - lib
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ required_rubygems_version: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ requirements: []
210
+ rubyforge_project:
211
+ rubygems_version: 2.7.6
212
+ signing_key:
213
+ specification_version: 4
214
+ summary: Tools for working with the quadtone printing process
215
+ test_files: []