ruby-vips 2.0.14 → 2.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -1
- data/.rubocop_todo.yml +32 -247
- data/CHANGELOG.md +6 -0
- data/TODO +11 -3
- data/VERSION +1 -1
- data/example/daltonize8.rb +13 -15
- data/example/example1.rb +1 -2
- data/example/example4.rb +2 -2
- data/example/example5.rb +4 -5
- data/example/inheritance_with_refcount.rb +2 -19
- data/example/thumb.rb +2 -4
- data/example/trim8.rb +4 -4
- data/lib/vips.rb +10 -16
- data/lib/vips/align.rb +0 -1
- data/lib/vips/angle.rb +0 -1
- data/lib/vips/angle45.rb +0 -1
- data/lib/vips/bandformat.rb +0 -2
- data/lib/vips/blend_mode.rb +0 -2
- data/lib/vips/coding.rb +0 -1
- data/lib/vips/compass_direction.rb +0 -1
- data/lib/vips/direction.rb +0 -1
- data/lib/vips/extend.rb +0 -1
- data/lib/vips/gobject.rb +0 -4
- data/lib/vips/gvalue.rb +3 -9
- data/lib/vips/image.rb +64 -67
- data/lib/vips/interesting.rb +0 -1
- data/lib/vips/interpolate.rb +0 -5
- data/lib/vips/interpretation.rb +0 -1
- data/lib/vips/kernel.rb +0 -1
- data/lib/vips/methods.rb +3 -3
- data/lib/vips/object.rb +10 -17
- data/lib/vips/operation.rb +26 -34
- data/lib/vips/operationboolean.rb +0 -1
- data/lib/vips/operationcomplex.rb +0 -1
- data/lib/vips/operationcomplex2.rb +0 -1
- data/lib/vips/operationcomplexget.rb +0 -1
- data/lib/vips/operationmath.rb +0 -1
- data/lib/vips/operationmath2.rb +0 -1
- data/lib/vips/operationrelational.rb +0 -1
- data/lib/vips/operationround.rb +0 -1
- data/lib/vips/size.rb +0 -1
- data/lib/vips/version.rb +1 -2
- data/ruby-vips.gemspec +0 -1
- metadata +3 -4
data/lib/vips/methods.rb
CHANGED
@@ -230,12 +230,12 @@ module Vips
|
|
230
230
|
# @!method project(**opts)
|
231
231
|
# Find image projections.
|
232
232
|
# @param opts [Hash] Set of options
|
233
|
-
# @return [Array<] Sums of columns, Sums of rows
|
233
|
+
# @return [Array<Vips::Image, Vips::Image>] Sums of columns, Sums of rows
|
234
234
|
|
235
235
|
# @!method profile(**opts)
|
236
236
|
# Find image profiles.
|
237
237
|
# @param opts [Hash] Set of options
|
238
|
-
# @return [Array<] First non-zero pixel in column, First non-zero pixel in row
|
238
|
+
# @return [Array<Vips::Image, Vips::Image>] First non-zero pixel in column, First non-zero pixel in row
|
239
239
|
|
240
240
|
# @!method measure(h, v, **opts)
|
241
241
|
# Measure a set of patches on a color chart.
|
@@ -260,7 +260,7 @@ module Vips
|
|
260
260
|
# @param opts [Hash] Set of options
|
261
261
|
# @option opts [Float] :threshold Object threshold
|
262
262
|
# @option opts [Array<Double>] :background Color for background pixels
|
263
|
-
# @return [Array<] Left edge of image, Top edge of extract area, Width of extract area, Height of extract area
|
263
|
+
# @return [Array<Integer, Integer, Integer, Integer>] Left edge of image, Top edge of extract area, Width of extract area, Height of extract area
|
264
264
|
|
265
265
|
# @!method copy(**opts)
|
266
266
|
# Copy an image.
|
data/lib/vips/object.rb
CHANGED
@@ -78,7 +78,6 @@ module Vips
|
|
78
78
|
attach_function :type_find, :vips_type_find, [:string, :string], :GType
|
79
79
|
|
80
80
|
class Object < GObject::GObject
|
81
|
-
|
82
81
|
# print all active VipsObjects, with their reference counts. Handy for
|
83
82
|
# debugging ruby-vips.
|
84
83
|
def self.print_all
|
@@ -107,12 +106,10 @@ module Vips
|
|
107
106
|
|
108
107
|
class Struct < GObject::GObject::Struct
|
109
108
|
include ObjectLayout
|
110
|
-
|
111
109
|
end
|
112
110
|
|
113
111
|
class ManagedStruct < GObject::GObject::ManagedStruct
|
114
112
|
include ObjectLayout
|
115
|
-
|
116
113
|
end
|
117
114
|
|
118
115
|
# return a pspec, or nil ... nil wil leave a message in the error log
|
@@ -155,13 +152,13 @@ module Vips
|
|
155
152
|
GObject::g_object_get_property self, name, gvalue
|
156
153
|
result = gvalue.get
|
157
154
|
|
158
|
-
GLib::logger.debug("Vips::Object.get") {"#{name} == #{result}"}
|
155
|
+
GLib::logger.debug("Vips::Object.get") { "#{name} == #{result}" }
|
159
156
|
|
160
157
|
return result
|
161
158
|
end
|
162
159
|
|
163
160
|
def set name, value
|
164
|
-
GLib::logger.debug("Vips::Object.set") {"#{name} = #{value}"}
|
161
|
+
GLib::logger.debug("Vips::Object.set") { "#{name} = #{value}" }
|
165
162
|
|
166
163
|
gtype = get_typeof_error name
|
167
164
|
gvalue = GObject::GValue.alloc
|
@@ -169,7 +166,6 @@ module Vips
|
|
169
166
|
gvalue.set value
|
170
167
|
GObject::g_object_set_property self, name, gvalue
|
171
168
|
end
|
172
|
-
|
173
169
|
end
|
174
170
|
|
175
171
|
class ObjectClass < FFI::Struct
|
@@ -196,14 +192,14 @@ module Vips
|
|
196
192
|
ARGUMENT_MODIFY = 128
|
197
193
|
|
198
194
|
ARGUMENT_FLAGS = {
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
195
|
+
required: ARGUMENT_REQUIRED,
|
196
|
+
construct: ARGUMENT_CONSTRUCT,
|
197
|
+
set_once: ARGUMENT_SET_ONCE,
|
198
|
+
set_always: ARGUMENT_SET_ALWAYS,
|
199
|
+
input: ARGUMENT_INPUT,
|
200
|
+
output: ARGUMENT_OUTPUT,
|
201
|
+
deprecated: ARGUMENT_DEPRECATED,
|
202
|
+
modify: ARGUMENT_MODIFY
|
207
203
|
}
|
208
204
|
|
209
205
|
class ArgumentClass < Argument
|
@@ -238,7 +234,4 @@ module Vips
|
|
238
234
|
attach_function :vips_type_map, [:GType, :type_map_fn, :pointer], :pointer
|
239
235
|
|
240
236
|
attach_function :vips_object_get_description, [:pointer], :string
|
241
|
-
|
242
237
|
end
|
243
|
-
|
244
|
-
|
data/lib/vips/operation.rb
CHANGED
@@ -28,15 +28,14 @@ module Vips
|
|
28
28
|
OPERATION_DEPRECATED = 8
|
29
29
|
|
30
30
|
OPERATION_FLAGS = {
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
sequential: OPERATION_SEQUENTIAL,
|
32
|
+
nocache: OPERATION_NOCACHE,
|
33
|
+
deprecated: OPERATION_DEPRECATED
|
34
34
|
}
|
35
35
|
|
36
36
|
attach_function :vips_operation_get_flags, [:pointer], :int
|
37
37
|
|
38
38
|
class Operation < Object
|
39
|
-
|
40
39
|
# the layout of the VipsOperation struct
|
41
40
|
module OperationLayout
|
42
41
|
def self.included base
|
@@ -49,12 +48,10 @@ module Vips
|
|
49
48
|
|
50
49
|
class Struct < Object::Struct
|
51
50
|
include OperationLayout
|
52
|
-
|
53
51
|
end
|
54
52
|
|
55
53
|
class ManagedStruct < Object::ManagedStruct
|
56
54
|
include OperationLayout
|
57
|
-
|
58
55
|
end
|
59
56
|
|
60
57
|
def initialize value
|
@@ -78,7 +75,7 @@ module Vips
|
|
78
75
|
end
|
79
76
|
|
80
77
|
def argument_map &block
|
81
|
-
fn = Proc.new do |
|
78
|
+
fn = Proc.new do |_op, pspec, argument_class, argument_instance, _a, _b|
|
82
79
|
block.call pspec, argument_class, argument_instance
|
83
80
|
end
|
84
81
|
|
@@ -93,7 +90,7 @@ module Vips
|
|
93
90
|
def get_construct_args
|
94
91
|
args = []
|
95
92
|
|
96
|
-
argument_map do |pspec, argument_class,
|
93
|
+
argument_map do |pspec, argument_class, _argument_instance|
|
97
94
|
flags = argument_class[:flags]
|
98
95
|
if (flags & ARGUMENT_CONSTRUCT) != 0
|
99
96
|
# names can include - as punctuation, but we always use _ in
|
@@ -113,7 +110,7 @@ module Vips
|
|
113
110
|
return object if block.call object
|
114
111
|
|
115
112
|
if object.is_a? Enumerable
|
116
|
-
object.find {|value| block.call value, block}
|
113
|
+
object.find { |value| block.call value, block }
|
117
114
|
end
|
118
115
|
|
119
116
|
return nil
|
@@ -126,7 +123,7 @@ module Vips
|
|
126
123
|
# 2D array values become tiny 2D images
|
127
124
|
# if there's nothing to match to, we also make a 2D image
|
128
125
|
if (value.is_a?(Array) && value[0].is_a?(Array)) ||
|
129
|
-
|
126
|
+
match_image == nil
|
130
127
|
return Image.new_from_array value
|
131
128
|
else
|
132
129
|
# we have a 1D array ... use that as a pixel constant and
|
@@ -148,7 +145,7 @@ module Vips
|
|
148
145
|
value = value.copy.copy_memory
|
149
146
|
end
|
150
147
|
elsif gtype == ARRAY_IMAGE_TYPE
|
151
|
-
value = value.map {|x| Operation::imageize match_image, x}
|
148
|
+
value = value.map { |x| Operation::imageize match_image, x }
|
152
149
|
end
|
153
150
|
|
154
151
|
super name, value
|
@@ -226,7 +223,7 @@ module Vips
|
|
226
223
|
def self.call name, supplied, optional = {}, option_string = ""
|
227
224
|
GLib::logger.debug("Vips::VipsOperation.call") {
|
228
225
|
"name = #{name}, supplied = #{supplied}, " +
|
229
|
-
|
226
|
+
"optional = #{optional}, option_string = #{option_string}"
|
230
227
|
}
|
231
228
|
|
232
229
|
op = Operation.new name
|
@@ -237,55 +234,54 @@ module Vips
|
|
237
234
|
optional_input = {}
|
238
235
|
required_output = []
|
239
236
|
optional_output = {}
|
240
|
-
args.each do |
|
237
|
+
args.each do |arg_name, flags|
|
241
238
|
next if (flags & ARGUMENT_DEPRECATED) != 0
|
242
239
|
|
243
240
|
if (flags & ARGUMENT_INPUT) != 0
|
244
241
|
if (flags & ARGUMENT_REQUIRED) != 0
|
245
|
-
required_input << [
|
242
|
+
required_input << [arg_name, flags]
|
246
243
|
else
|
247
|
-
optional_input[
|
244
|
+
optional_input[arg_name] = flags
|
248
245
|
end
|
249
246
|
end
|
250
247
|
|
251
248
|
# MODIFY INPUT args count as OUTPUT as well
|
252
249
|
if (flags & ARGUMENT_OUTPUT) != 0 ||
|
253
|
-
|
254
|
-
|
250
|
+
((flags & ARGUMENT_INPUT) != 0 &&
|
251
|
+
(flags & ARGUMENT_MODIFY) != 0)
|
255
252
|
if (flags & ARGUMENT_REQUIRED) != 0
|
256
|
-
required_output << [
|
253
|
+
required_output << [arg_name, flags]
|
257
254
|
else
|
258
|
-
optional_output[
|
255
|
+
optional_output[arg_name] = flags
|
259
256
|
end
|
260
257
|
end
|
261
|
-
|
262
258
|
end
|
263
259
|
|
264
260
|
# so we should have been supplied with n_required_input values, or
|
265
261
|
# n_required_input + 1 if there's a hash of options at the end
|
266
262
|
unless supplied.is_a? Array
|
267
263
|
raise Vips::Error, "unable to call #{name}: " +
|
268
|
-
|
264
|
+
"argument array is not an array"
|
269
265
|
end
|
270
266
|
unless optional.is_a? Hash
|
271
267
|
raise Vips::Error, "unable to call #{name}: " +
|
272
|
-
|
268
|
+
"optional arguments are not a hash"
|
273
269
|
end
|
274
270
|
if supplied.length != required_input.length
|
275
271
|
raise Vips::Error, "unable to call #{name}: " +
|
276
|
-
|
277
|
-
|
272
|
+
"you supplied #{supplied.length} arguments, " +
|
273
|
+
"but operation needs #{required_input.length}."
|
278
274
|
end
|
279
275
|
|
280
276
|
# very that all supplied_optional keys are in optional_input or
|
281
277
|
# optional_output
|
282
|
-
optional.each do |key,
|
278
|
+
optional.each do |key, _value|
|
283
279
|
arg_name = key.to_s
|
284
280
|
|
285
281
|
unless optional_input.has_key?(arg_name) ||
|
286
|
-
|
282
|
+
optional_output.has_key?(arg_name)
|
287
283
|
raise Vips::Error, "unable to call #{name}: " +
|
288
|
-
|
284
|
+
"unknown option #{arg_name}"
|
289
285
|
end
|
290
286
|
end
|
291
287
|
|
@@ -331,18 +327,16 @@ module Vips
|
|
331
327
|
|
332
328
|
# get all required results
|
333
329
|
result = []
|
334
|
-
required_output.each do |arg_name,
|
330
|
+
required_output.each do |arg_name, _flags|
|
335
331
|
result << op.get(arg_name)
|
336
332
|
end
|
337
333
|
|
338
334
|
# fetch all optional ones
|
339
335
|
optional_results = {}
|
340
|
-
optional.each do |key,
|
336
|
+
optional.each do |key, _value|
|
341
337
|
arg_name = key.to_s
|
342
338
|
|
343
339
|
if optional_output.has_key? arg_name
|
344
|
-
flags = optional_output[arg_name]
|
345
|
-
|
346
340
|
optional_results[arg_name] = op.get arg_name
|
347
341
|
end
|
348
342
|
end
|
@@ -355,13 +349,11 @@ module Vips
|
|
355
349
|
result = nil
|
356
350
|
end
|
357
351
|
|
358
|
-
GLib::logger.debug("Vips::Operation.call") {"result = #{result}"}
|
352
|
+
GLib::logger.debug("Vips::Operation.call") { "result = #{result}" }
|
359
353
|
|
360
354
|
Vips::vips_object_unref_outputs op
|
361
355
|
|
362
356
|
return result
|
363
357
|
end
|
364
|
-
|
365
358
|
end
|
366
|
-
|
367
359
|
end
|
data/lib/vips/operationmath.rb
CHANGED
data/lib/vips/operationmath2.rb
CHANGED
data/lib/vips/operationround.rb
CHANGED
data/lib/vips/size.rb
CHANGED
data/lib/vips/version.rb
CHANGED
data/ruby-vips.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-vips
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Cupitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -215,8 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
215
|
- !ruby/object:Gem::Version
|
216
216
|
version: '0'
|
217
217
|
requirements: []
|
218
|
-
|
219
|
-
rubygems_version: 2.7.6.2
|
218
|
+
rubygems_version: 3.0.6
|
220
219
|
signing_key:
|
221
220
|
specification_version: 4
|
222
221
|
summary: Ruby extension for the vips image processing library.
|