ruby-vips 0.3.14 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +22 -0
  3. data/CHANGELOG.md +4 -0
  4. data/Gemfile +15 -0
  5. data/Gemfile.lock +46 -31
  6. data/{LICENSE → LICENSE.txt} +1 -1
  7. data/README.md +101 -145
  8. data/Rakefile +45 -0
  9. data/TODO +8 -32
  10. data/VERSION +1 -0
  11. data/example/annotate.rb +17 -0
  12. data/example/daltonize8.rb +75 -0
  13. data/example/example1.rb +84 -0
  14. data/example/example2.rb +31 -0
  15. data/example/example3.rb +19 -0
  16. data/example/example4.rb +18 -0
  17. data/example/example5.rb +31 -0
  18. data/example/trim8.rb +41 -0
  19. data/example/watermark.rb +44 -0
  20. data/example/wobble.rb +36 -0
  21. data/lib/vips.rb +151 -14
  22. data/lib/vips/access.rb +14 -0
  23. data/lib/vips/align.rb +11 -0
  24. data/lib/vips/angle.rb +12 -0
  25. data/lib/vips/angle45.rb +16 -0
  26. data/lib/vips/argument.rb +163 -0
  27. data/lib/vips/bandformat.rb +20 -0
  28. data/lib/vips/call.rb +302 -0
  29. data/lib/vips/coding.rb +14 -0
  30. data/lib/vips/demandstyle.rb +35 -0
  31. data/lib/vips/direction.rb +11 -0
  32. data/lib/vips/error.rb +30 -0
  33. data/lib/vips/extend.rb +22 -0
  34. data/lib/vips/foreignflags.rb +20 -0
  35. data/lib/vips/image.rb +1382 -0
  36. data/lib/vips/interpolate.rb +37 -0
  37. data/lib/vips/interpretation.rb +28 -0
  38. data/lib/vips/methods.rb +1807 -0
  39. data/lib/vips/operation.rb +19 -0
  40. data/ruby-vips8.gemspec +112 -0
  41. data/spec/image_spec.rb +515 -0
  42. data/spec/samples/balloon.v +0 -0
  43. data/spec/samples/ghost.ppm +405 -0
  44. data/spec/samples/huge.jpg +0 -0
  45. data/spec/samples/icc.jpg +0 -0
  46. data/spec/samples/lcd.icc +0 -0
  47. data/spec/samples/lion.svg +154 -0
  48. data/spec/samples/sample.csv +7 -0
  49. data/spec/samples/sample.exr +0 -0
  50. data/spec/samples/wagon.jpg +0 -0
  51. data/spec/samples/wagon.v +0 -0
  52. data/spec/spec_helper.rb +49 -0
  53. data/spec/vips_spec.rb +74 -0
  54. metadata +110 -70
  55. data/ext/extconf.rb +0 -31
  56. data/ext/header.c +0 -457
  57. data/ext/header.h +0 -9
  58. data/ext/image.c +0 -629
  59. data/ext/image.h +0 -72
  60. data/ext/image_arithmetic.c +0 -936
  61. data/ext/image_arithmetic.h +0 -38
  62. data/ext/image_boolean.c +0 -301
  63. data/ext/image_boolean.h +0 -8
  64. data/ext/image_colour.c +0 -590
  65. data/ext/image_colour.h +0 -36
  66. data/ext/image_conversion.c +0 -884
  67. data/ext/image_conversion.h +0 -38
  68. data/ext/image_convolution.c +0 -368
  69. data/ext/image_convolution.h +0 -13
  70. data/ext/image_freq_filt.c +0 -740
  71. data/ext/image_freq_filt.h +0 -27
  72. data/ext/image_histograms_lut.c +0 -643
  73. data/ext/image_histograms_lut.h +0 -28
  74. data/ext/image_morphology.c +0 -327
  75. data/ext/image_morphology.h +0 -13
  76. data/ext/image_mosaicing.c +0 -554
  77. data/ext/image_mosaicing.h +0 -15
  78. data/ext/image_relational.c +0 -384
  79. data/ext/image_relational.h +0 -8
  80. data/ext/image_resample.c +0 -249
  81. data/ext/image_resample.h +0 -9
  82. data/ext/interpolator.c +0 -106
  83. data/ext/interpolator.h +0 -7
  84. data/ext/mask.c +0 -347
  85. data/ext/mask.h +0 -18
  86. data/ext/reader.c +0 -261
  87. data/ext/reader.h +0 -2
  88. data/ext/ruby_vips.c +0 -188
  89. data/ext/ruby_vips.h +0 -72
  90. data/ext/tags +0 -450
  91. data/ext/writer.c +0 -371
  92. data/ext/writer.h +0 -2
  93. data/lib/vips/reader.rb +0 -272
  94. data/lib/vips/version.rb +0 -3
  95. data/lib/vips/writer.rb +0 -342
  96. data/ruby-vips.gemspec +0 -100
  97. data/ruby.supp +0 -134
@@ -1,3 +0,0 @@
1
- module VIPS
2
- VERSION = "0.3.14"
3
- end
@@ -1,342 +0,0 @@
1
- module VIPS
2
- class Writer
3
- def write(path)
4
- write_gc path
5
- end
6
-
7
- private
8
-
9
- # write can fail due to no file descriptors, memory can fill if large
10
- # objects are not collected fairly soon
11
- #
12
- # we can't try a write and GC and retry on fail, since the write may take a
13
- # long time
14
- #
15
- # GCing before every write would have a horrible effect on performance, so
16
- # as a compromise we GC every @@gc_interval writes
17
- #
18
- # ruby2.1 introduced a generational GC which
19
- # is fast enough to be able to GC on every write
20
-
21
- @@generational_gc = RUBY_ENGINE == "ruby" && RUBY_VERSION.to_f >= 2.1
22
-
23
- @@gc_interval = 100
24
- @@gc_countdown = @@gc_interval
25
-
26
- def write_gc(path)
27
- if @@generational_gc
28
- GC.start full_mark: false
29
- else
30
- @@gc_countdown -= 1
31
- if @@gc_countdown < 0
32
- @@gc_countdown = @@gc_interval
33
- GC.start
34
- end
35
- end
36
-
37
- write_internal path
38
- end
39
- end
40
-
41
- class CSVWriter < Writer
42
- attr_accessor :separator
43
-
44
- def initialize(image, options={})
45
- super image
46
- @separator = "\t"
47
-
48
- self.separator = options[:separator] if options.has_key?(:separator)
49
- end
50
-
51
- def write(path)
52
- write_gc "#{path}:sep:#{@separator}"
53
- end
54
- end
55
-
56
- class JPEGWriter < Writer
57
- attr_reader :quality
58
-
59
- def initialize(image, options={})
60
- super image
61
-
62
- @quality = 75
63
-
64
- self.quality = options[:quality] if options.has_key?(:quality)
65
- end
66
-
67
- def write(path)
68
- write_gc "#{path}:#{@quality}"
69
- end
70
-
71
- def to_memory
72
- buf_internal @quality
73
- end
74
-
75
- def quality=(quality_v)
76
- unless (0..100).include?(quality_v)
77
- raise ArgumentError, 'quality must be a numeric value between 0 and 100'
78
- end
79
-
80
- @quality = quality_v
81
- end
82
- end
83
-
84
- class PNGWriter < Writer
85
- attr_reader :compression
86
- attr_accessor :interlace
87
-
88
- def initialize(image, options={})
89
- super image
90
-
91
- @compression = 6
92
- @interlace = false
93
-
94
- self.compression = options[:compression] if options.has_key?(:compression)
95
- self.interlace = options[:interlace] if options.has_key?(:interlace)
96
- end
97
-
98
- def write(path)
99
- write_gc "#{path}:#{@compression},#{@interlace ? 1 : 0}"
100
- end
101
-
102
- def to_memory
103
- buf_internal @compression, (@interlace ? 1 : 0)
104
- end
105
-
106
- def compression=(compression_v)
107
- unless (0..9).include?(compression_v)
108
- raise ArgumentError, 'compression must be a numeric value between 0 and 9'
109
- end
110
-
111
- @compression = compression_v
112
- end
113
- end
114
-
115
- class WEBPWriter < Writer
116
- attr_accessor :quality, :lossless
117
-
118
- def initialize(image, options={})
119
- super image
120
-
121
- @quality = 75
122
- @lossless = false
123
-
124
- self.quality = options[:quality] if options.has_key?(:quality)
125
- self.lossless = options[:lossless] if options.has_key?(:lossless)
126
- end
127
-
128
- def write(path)
129
- write_gc "#{path}:#{@quality},#{@lossless ? 1 : 0}"
130
- end
131
-
132
- def quality=(quality_v)
133
- unless (0..100).include?(quality_v)
134
- raise ArgumentError, 'quality must be a numeric value between 0 and 100'
135
- end
136
-
137
- @quality = quality_v
138
- end
139
-
140
- def lossless=(lossless_v)
141
- unless [True, False].include?(lossless_v)
142
- raise ArgumentError, 'lossless must be a boolean value'
143
- end
144
-
145
- @lossless = lossless_v
146
- end
147
- end
148
-
149
- class PPMWriter < Writer
150
- attr_reader :format
151
-
152
- FORMAT = [:binary, :ascii]
153
-
154
- def initialize(image, options={})
155
- super image
156
-
157
- @format = :binary
158
-
159
- self.format = options[:format] if options.has_key?(:format)
160
- end
161
-
162
- def write(path)
163
- write_gc "#{path}:#{@format}"
164
- end
165
-
166
- def format=(format_v)
167
- unless FORMAT.include?(format_v)
168
- raise ArgumentError, "format must be one of #{FORMAT.join(', ')}"
169
- end
170
-
171
- @format = format_v
172
- end
173
- end
174
-
175
- class TIFFWriter < Writer
176
- attr_reader :compression, :layout, :multi_res, :format, :resolution_units,
177
- :resolution, :predictor, :quality, :tile_size
178
-
179
- COMPRESSION = [:none, :jpeg, :deflate, :packbits, :ccittfax4, :lzw]
180
- PREDICTOR = [:none, :horizontal_differencing, :floating_point]
181
- LAYOUT = [:strip, :tile]
182
- MULTI_RES = [:flat, :pyramid]
183
- FORMAT = [:manybit, :onebit]
184
- RESOLUTION_UNITS = [:cm, :inch]
185
-
186
- def initialize(image, options={})
187
- super image
188
-
189
- @compression = :none
190
- @quality = 75
191
- @predictor = :none
192
- @layout = :strip
193
- @tile_size = [128, 128]
194
- @multi_res = :flat
195
- @format = :manybit
196
- @resolution_units = :cm
197
-
198
- [ :compression, :layout, :multi_res, :format, :resolution_units,
199
- :resolution, :predictor, :quality, :tile_size ].each do |att|
200
- self.send "#{att}=".to_sym, options[att] if options.has_key?(att)
201
- end
202
- end
203
-
204
- def write(path)
205
- opts = [compression_str, layout_str, @multi_res, @format, resolution_str].join ','
206
- write_gc "#{path}:#{opts}"
207
- end
208
-
209
- def compression_str
210
- case @compression
211
- when :jpeg then "#{@compression}:#{@quality}"
212
- when :lzw, :deflate then "#{@compression}:#{@predictor}"
213
- else @compression
214
- end
215
- end
216
-
217
- def layout_str
218
- s = @layout.to_s
219
- s << ":#{@tile_size.join 'x'}" if @layout == :tile
220
- s
221
- end
222
-
223
- def resolution_str
224
- s = "res_#{@resolution_units}"
225
- s << ":#{@resolution.join 'x'}" if @resolution
226
- s
227
- end
228
-
229
- def compression=(compression_v)
230
- unless COMPRESSION.include?(compression_v)
231
- raise ArgumentError, "compression must be one of #{COMPRESSION.join(', ')}"
232
- end
233
-
234
- @compression = compression_v
235
- end
236
-
237
- def quality=(quality_v)
238
- unless (0..100).include?(quality_v)
239
- raise ArgumentError, 'quality must be a numeric value between 0 and 100'
240
- end
241
-
242
- @quality = quality_v
243
- end
244
-
245
- def predictor=(predictor_v)
246
- unless PREDICTOR.include?(predictor_v)
247
- raise ArgumentError, "predictor must be one of #{PREDICTOR.join(', ')}"
248
- end
249
-
250
- @predictor = predictor_v
251
- end
252
-
253
- def layout=(layout_v)
254
- unless LAYOUT.include?(layout_v)
255
- raise ArgumentError, "layout must be one of #{LAYOUT.join(', ')}"
256
- end
257
-
258
- @layout = layout_v
259
- end
260
-
261
- def tile_size=(tile_size_v)
262
- unless tile_size_v[0] > 1 && tile_size_v[1] > 1
263
- raise ArgumentError, "tile sizes must be larger than 1"
264
- end
265
-
266
- @tile_size = tile_size_v
267
- end
268
-
269
- def multi_res=(multi_res_v)
270
- unless MULTI_RES.include?(multi_res_v)
271
- raise ArgumentError, "multi res must be one of #{MULTI_RES.join(', ')}"
272
- end
273
-
274
- @multi_res = multi_res_v
275
- end
276
-
277
- def format=(format_v)
278
- unless FORMAT.include?(format_v)
279
- raise ArgumentError, "format must be one of #{FORMAT.join(', ')}"
280
- end
281
-
282
- @format = format_v
283
- end
284
-
285
- def resolution_units=(resolution_units_v)
286
- unless RESOLUTION_UNITS.include?(resolution_units_v)
287
- raise ArgumentError, "Resolution units must be one of #{RESOLUTION_UNITS.join(', ')}"
288
- end
289
-
290
- @resolution_units = resolution_units_v
291
- end
292
-
293
- def resolution=(resolution_v)
294
- unless resolution_v[0] > 0 && resolution_v[1] > 0
295
- raise ArgumentError, "Resolution must have a height and width larger than 0"
296
- end
297
-
298
- @resolution = resolution_v
299
- end
300
- end
301
-
302
- class Image
303
- def csv(*args)
304
- invoke_writer CSVWriter, *args
305
- end
306
-
307
- def jpeg(*args)
308
- invoke_writer JPEGWriter, *args
309
- end
310
-
311
- def png(*args)
312
- invoke_writer PNGWriter, *args
313
- end
314
-
315
- def ppm(*args)
316
- invoke_writer PPMWriter, *args
317
- end
318
-
319
- def tiff(*args)
320
- invoke_writer TIFFWriter, *args
321
- end
322
-
323
- def vips(*args)
324
- invoke_writer VIPSWriter, *args
325
- end
326
-
327
- def write(*args)
328
- invoke_writer Writer, *args
329
- end
330
-
331
- private
332
-
333
- def invoke_writer(writer_class, path=nil, options={})
334
- w = writer_class.new self, options
335
- if path
336
- w.write path
337
- else
338
- w
339
- end
340
- end
341
- end
342
- end
@@ -1,100 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: ruby-vips 0.3.14 ruby lib
6
- # stub: ext/extconf.rb
7
-
8
- Gem::Specification.new do |s|
9
- s.name = "ruby-vips"
10
- s.version = "0.3.14"
11
-
12
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
- s.require_paths = ["lib"]
14
- s.authors = ["Timothy Elliott", "John Cupitt"]
15
- s.date = "2016-01-25"
16
- s.description = "Ruby extension for the vips image processing library."
17
- s.email = "jcupitt@gmail.com"
18
- s.extensions = ["ext/extconf.rb"]
19
- s.extra_rdoc_files = [
20
- "LICENSE",
21
- "README.md",
22
- "TODO"
23
- ]
24
- s.files = [
25
- "CHANGELOG.md",
26
- "Gemfile.lock",
27
- "README.md",
28
- "ext/extconf.rb",
29
- "ext/header.c",
30
- "ext/header.h",
31
- "ext/image.c",
32
- "ext/image.h",
33
- "ext/image_arithmetic.c",
34
- "ext/image_arithmetic.h",
35
- "ext/image_boolean.c",
36
- "ext/image_boolean.h",
37
- "ext/image_colour.c",
38
- "ext/image_colour.h",
39
- "ext/image_conversion.c",
40
- "ext/image_conversion.h",
41
- "ext/image_convolution.c",
42
- "ext/image_convolution.h",
43
- "ext/image_freq_filt.c",
44
- "ext/image_freq_filt.h",
45
- "ext/image_histograms_lut.c",
46
- "ext/image_histograms_lut.h",
47
- "ext/image_morphology.c",
48
- "ext/image_morphology.h",
49
- "ext/image_mosaicing.c",
50
- "ext/image_mosaicing.h",
51
- "ext/image_relational.c",
52
- "ext/image_relational.h",
53
- "ext/image_resample.c",
54
- "ext/image_resample.h",
55
- "ext/interpolator.c",
56
- "ext/interpolator.h",
57
- "ext/mask.c",
58
- "ext/mask.h",
59
- "ext/reader.c",
60
- "ext/reader.h",
61
- "ext/ruby_vips.c",
62
- "ext/ruby_vips.h",
63
- "ext/tags",
64
- "ext/writer.c",
65
- "ext/writer.h",
66
- "lib/vips.rb",
67
- "lib/vips/reader.rb",
68
- "lib/vips/version.rb",
69
- "lib/vips/writer.rb",
70
- "ruby-vips.gemspec",
71
- "ruby.supp"
72
- ]
73
- s.homepage = "http://github.com/jcupitt/ruby-vips"
74
- s.licenses = ["MIT"]
75
- s.rdoc_options = ["--title", "ruby-vips \#{version}", "ext"]
76
- s.rubygems_version = "2.2.2"
77
- s.summary = "ruby-vips is a ruby extension for vips. It is extremely fast and it can process huge images without requiring the entire image to be loaded into memory."
78
-
79
- if s.respond_to? :specification_version then
80
- s.specification_version = 4
81
-
82
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
83
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
84
- s.add_development_dependency(%q<bundler>, ["~> 1.0"])
85
- s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
86
- s.add_development_dependency(%q<rspec>, ["~> 3.4"])
87
- else
88
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
89
- s.add_dependency(%q<bundler>, ["~> 1.0"])
90
- s.add_dependency(%q<jeweler>, ["~> 1.8"])
91
- s.add_dependency(%q<rspec>, ["~> 3.4"])
92
- end
93
- else
94
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
95
- s.add_dependency(%q<bundler>, ["~> 1.0"])
96
- s.add_dependency(%q<jeweler>, ["~> 1.8"])
97
- s.add_dependency(%q<rspec>, ["~> 3.4"])
98
- end
99
- end
100
-
data/ruby.supp DELETED
@@ -1,134 +0,0 @@
1
- # valgrind suppressions file for ruby1.9.1
2
-
3
- # handy for debugging spec fails, eg.
4
- #
5
- # $ export G_DEBUG=gc-friendly
6
- # $ export G_SLICE=always-malloc
7
- # $ valgrind --db-attach=yes -- ruby -S rspec spec/vips/morphology_spec.rb
8
-
9
- {
10
- ruby1
11
- Memcheck:Cond
12
- ...
13
- fun:rb_parser_compile_file
14
- }
15
-
16
- {
17
- ruby2
18
- Memcheck:Value8
19
- ...
20
- fun:rb_parser_compile_file
21
- }
22
-
23
- {
24
- ruby3
25
- Memcheck:Cond
26
- ...
27
- fun:rb_file_expand_path
28
- }
29
-
30
- {
31
- ruby4
32
- Memcheck:Value8
33
- ...
34
- fun:rb_file_expand_path
35
- }
36
-
37
- # happens a lot during compile
38
- {
39
- ruby5
40
- Memcheck:Addr4
41
- obj:/usr/lib/libruby-1.9.1.so.1.9.1
42
- ...
43
- fun:rb_ary_each
44
- }
45
-
46
- {
47
- ruby5a
48
- Memcheck:Cond
49
- obj:/usr/lib/libruby-1.9.1.so.1.9.1
50
- fun:rb_newobj
51
- }
52
-
53
- {
54
- ruby6
55
- Memcheck:Cond
56
- ...
57
- fun:rb_iseq_compile_with_option
58
- }
59
-
60
- {
61
- ruby7
62
- Memcheck:Value8
63
- ...
64
- fun:rb_iseq_compile_with_option
65
- }
66
-
67
- {
68
- ruby8
69
- Memcheck:Cond
70
- ...
71
- fun:st_init_table_with_size
72
- }
73
-
74
- {
75
- ruby9
76
- Memcheck:Value8
77
- ...
78
- fun:st_init_table_with_size
79
- }
80
-
81
- {
82
- ruby10
83
- Memcheck:Cond
84
- ...
85
- fun:rb_iseq_compile_node
86
- }
87
-
88
- {
89
- ruby11
90
- Memcheck:Value8
91
- ...
92
- fun:rb_iseq_compile_node
93
- }
94
-
95
- {
96
- ruby12
97
- Memcheck:Cond
98
- obj:/usr/lib/libruby-1.9.1.so.1.9.1
99
- ...
100
- fun:rb_node_newnode
101
- }
102
-
103
- {
104
- ruby13
105
- Memcheck:Value8
106
- obj:/usr/lib/libruby-1.9.1.so.1.9.1
107
- ...
108
- fun:rb_node_newnode
109
- }
110
-
111
- {
112
- ruby14
113
- Memcheck:Cond
114
- obj:/usr/lib/libruby-1.9.1.so.1.9.1
115
- ...
116
- fun:Init_sha1
117
- }
118
-
119
- {
120
- ruby15
121
- Memcheck:Addr8
122
- obj:/usr/lib/libruby-1.9.1.so.1.9.1
123
- ...
124
- fun:rb_yield
125
- }
126
-
127
- {
128
- ruby16
129
- Memcheck:Value8
130
- obj:/usr/lib/libruby-1.9.1.so.1.9.1
131
- fun:rb_newobj
132
- }
133
-
134
-