ruby-vips 2.0.7 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/VERSION +1 -1
- data/example/thumb.rb +31 -0
- data/lib/vips.rb +17 -2
- data/lib/vips/gvalue.rb +31 -22
- data/lib/vips/image.rb +49 -36
- data/lib/vips/object.rb +9 -2
- data/lib/vips/operation.rb +11 -10
- data/lib/vips/version.rb +1 -1
- data/ruby-vips.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3053302bf9707cbd283b0b8c1cf7add20cbe94bf
|
4
|
+
data.tar.gz: fc1c109a20fbd505a2e97227d02b8274c7385571
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7a50b059950e254e5743d193e565296721cd35d23278ec2480f86a6e049770eb1a06ee670d2f2e4163611d29442d4c3080b5b7352caeb10bcaa84e661202ce0
|
7
|
+
data.tar.gz: 0626521b21f79c42fe423a373cbfb67eb36296f6b692f039a9a0c997af142e7d2ffd65cdfe66fffcc952d4a9d95d0e4c7b1566e279e83f00cc407e82620a00b3
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## Version 2.0.8 (2017-09-14)
|
6
|
+
|
7
|
+
* add `thumb.rb` example, and verify we run stably and in constant memory
|
8
|
+
* cleanups and polish [Nakilon]
|
9
|
+
* add `composite` convenience method
|
10
|
+
* add `Vips::concurrency_set` and `Vips::vector_set`
|
11
|
+
|
5
12
|
## Version 2.0.7 (2017-09-08)
|
6
13
|
|
7
14
|
* disable the logging for now, it could deadlock
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.8
|
data/example/thumb.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# batch-process a lot of files
|
4
|
+
#
|
5
|
+
# this should run in constant memory -- if it doesn't, something has broken
|
6
|
+
|
7
|
+
require 'vips'
|
8
|
+
|
9
|
+
# benchmark thumbnail via a memory buffer
|
10
|
+
def via_memory(filename, thumbnail_width)
|
11
|
+
data = IO.binread(filename)
|
12
|
+
|
13
|
+
thumb = Vips::Image.thumbnail_buffer data, thumbnail_width, crop: 'centre'
|
14
|
+
|
15
|
+
thumb.write_to_buffer '.jpg'
|
16
|
+
end
|
17
|
+
|
18
|
+
# benchmark thumbnail via files
|
19
|
+
def via_files(filename, thumbnail_width)
|
20
|
+
thumb = Vips::Image.thumbnail filename, thumbnail_width, crop: 'centre'
|
21
|
+
|
22
|
+
thumb.write_to_buffer '.jpg'
|
23
|
+
end
|
24
|
+
|
25
|
+
ARGV.each do |filename|
|
26
|
+
puts "processing #{filename} ..."
|
27
|
+
thumb = via_memory(filename, 500)
|
28
|
+
# thumb = via_files(filename, 500)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
data/lib/vips.rb
CHANGED
@@ -71,7 +71,7 @@ module GLib
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def self.remove_log_handler
|
74
|
-
if @glib_log_handler_id != 0
|
74
|
+
if @glib_log_handler_id != 0 && @glib_log_domain
|
75
75
|
g_log_remove_handler @glib_log_domain, @glib_log_handler_id
|
76
76
|
@glib_log_handler_id = nil
|
77
77
|
end
|
@@ -510,6 +510,8 @@ module Vips
|
|
510
510
|
# in any case libvips does this for us
|
511
511
|
|
512
512
|
attach_function :vips_leak_set, [:int], :void
|
513
|
+
attach_function :vips_vector_set_enabled, [:int], :void
|
514
|
+
attach_function :vips_concurrency_set, [:int], :void
|
513
515
|
|
514
516
|
# Turn libvips leak testing on and off. Handy for debugging ruby-vips, not
|
515
517
|
# very useful for user code.
|
@@ -540,6 +542,19 @@ module Vips
|
|
540
542
|
vips_cache_set_max_files size
|
541
543
|
end
|
542
544
|
|
545
|
+
# Set the size of the libvips worker pool. This defaults to the number of
|
546
|
+
# hardware threads on your computer. Set to 1 to disable threading.
|
547
|
+
def self.concurrency_set n
|
548
|
+
vips_concurrency_set n
|
549
|
+
end
|
550
|
+
|
551
|
+
# Enable or disable SIMD and the run-time compiler. This can give a nice
|
552
|
+
# speed-up, but can also be unstable on some systems or with some versions
|
553
|
+
# of the run-time compiler.
|
554
|
+
def self.vector_set enabled
|
555
|
+
vips_vector_set_enabled(enabled ? 1 : 0)
|
556
|
+
end
|
557
|
+
|
543
558
|
# Deprecated compatibility function.
|
544
559
|
#
|
545
560
|
# Don't use this, instead change {GLib::logger.level}.
|
@@ -557,7 +572,7 @@ module Vips
|
|
557
572
|
major = version(0)
|
558
573
|
minor = version(1)
|
559
574
|
|
560
|
-
major > x
|
575
|
+
major > x || (major == x && minor >= y)
|
561
576
|
end
|
562
577
|
|
563
578
|
LIBRARY_VERSION = Vips::version_string
|
data/lib/vips/gvalue.rb
CHANGED
@@ -23,6 +23,30 @@ module GObject
|
|
23
23
|
layout :gtype, :GType,
|
24
24
|
:data, [:ulong_long, 2]
|
25
25
|
|
26
|
+
# convert an enum value (str/symb/int) into an int ready for libvips
|
27
|
+
def self.from_nick(gtype, value)
|
28
|
+
value = value.to_s if value.is_a? Symbol
|
29
|
+
|
30
|
+
if value.is_a? String
|
31
|
+
value = Vips::vips_enum_from_nick "ruby-vips", gtype, value
|
32
|
+
if value == -1
|
33
|
+
raise Vips::Error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
value
|
38
|
+
end
|
39
|
+
|
40
|
+
# convert an int enum back into a symbol
|
41
|
+
def self.to_nick(gtype, enum_value)
|
42
|
+
enum_name = Vips::vips_enum_nick gtype, enum_value
|
43
|
+
if enum_name == nil
|
44
|
+
raise Vips::Error
|
45
|
+
end
|
46
|
+
|
47
|
+
enum_name.to_sym
|
48
|
+
end
|
49
|
+
|
26
50
|
def self.release ptr
|
27
51
|
# GLib::logger.debug("GObject::GValue::release") {"ptr = #{ptr}"}
|
28
52
|
::GObject::g_value_unset ptr
|
@@ -82,14 +106,14 @@ module GObject
|
|
82
106
|
::Vips::vips_value_set_ref_string self, value
|
83
107
|
|
84
108
|
when Vips::ARRAY_INT_TYPE
|
85
|
-
value = [value]
|
109
|
+
value = [value] unless value.is_a? Array
|
86
110
|
|
87
111
|
Vips::vips_value_set_array_int self, nil, value.length
|
88
112
|
ptr = Vips::vips_value_get_array_int self, nil
|
89
113
|
ptr.write_array_of_int32 value
|
90
114
|
|
91
115
|
when Vips::ARRAY_DOUBLE_TYPE
|
92
|
-
value = [value]
|
116
|
+
value = [value] unless value.is_a? Array
|
93
117
|
|
94
118
|
# this will allocate an array in the gvalue
|
95
119
|
Vips::vips_value_set_array_double self, nil, value.length
|
@@ -100,7 +124,7 @@ module GObject
|
|
100
124
|
ptr.write_array_of_double value
|
101
125
|
|
102
126
|
when Vips::ARRAY_IMAGE_TYPE
|
103
|
-
value = [value]
|
127
|
+
value = [value] unless value.is_a? Array
|
104
128
|
|
105
129
|
Vips::vips_value_set_array_image self, value.length
|
106
130
|
ptr = Vips::vips_value_get_array_image self, nil
|
@@ -121,17 +145,8 @@ module GObject
|
|
121
145
|
::GObject::g_value_set_flags self, value
|
122
146
|
|
123
147
|
when GENUM_TYPE
|
124
|
-
|
125
|
-
|
126
|
-
if value.is_a? String
|
127
|
-
value = Vips::vips_enum_from_nick "ruby-vips",
|
128
|
-
self[:gtype], value
|
129
|
-
if value == -1
|
130
|
-
raise Vips::Error
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
::GObject::g_value_set_enum self, value
|
148
|
+
enum_value = GValue.from_nick(self[:gtype], value)
|
149
|
+
::GObject::g_value_set_enum self, enum_value
|
135
150
|
|
136
151
|
when GOBJECT_TYPE
|
137
152
|
::GObject::g_value_set_object self, value
|
@@ -200,14 +215,8 @@ module GObject
|
|
200
215
|
result = ::GObject::g_value_get_flags self
|
201
216
|
|
202
217
|
when GENUM_TYPE
|
203
|
-
enum_value = ::GObject::g_value_get_enum
|
204
|
-
|
205
|
-
# lifetime
|
206
|
-
enum_name = Vips::vips_enum_nick self[:gtype], enum_value
|
207
|
-
if enum_name == nil
|
208
|
-
raise Vips::Error
|
209
|
-
end
|
210
|
-
result = enum_name.to_sym
|
218
|
+
enum_value = ::GObject::g_value_get_enum(self)
|
219
|
+
result = GValue.to_nick self[:gtype], enum_value
|
211
220
|
|
212
221
|
when GOBJECT_TYPE
|
213
222
|
obj = ::GObject::g_value_get_object self
|
data/lib/vips/image.rb
CHANGED
@@ -82,14 +82,12 @@ module Vips
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def self.complex? format
|
85
|
-
format_number =
|
86
|
-
BAND_FORMAT_TYPE, format.to_s
|
85
|
+
format_number = GObject::GValue.from_nick BAND_FORMAT_TYPE, format
|
87
86
|
Vips::vips_band_format_iscomplex(format_number) != 0
|
88
87
|
end
|
89
88
|
|
90
89
|
def self.float? format
|
91
|
-
format_number =
|
92
|
-
BAND_FORMAT_TYPE, format.to_s
|
90
|
+
format_number = GObject::GValue.from_nick BAND_FORMAT_TYPE, format
|
93
91
|
Vips::vips_band_format_isfloat(format_number) != 0
|
94
92
|
end
|
95
93
|
|
@@ -99,12 +97,12 @@ module Vips
|
|
99
97
|
def self.run_cmplx image, &block
|
100
98
|
original_format = image.format
|
101
99
|
|
102
|
-
|
100
|
+
unless Image::complex? image.format
|
103
101
|
if image.bands % 2 != 0
|
104
102
|
raise Error, "not an even number of bands"
|
105
103
|
end
|
106
104
|
|
107
|
-
|
105
|
+
unless Image::float? image.format
|
108
106
|
image = image.cast :float
|
109
107
|
end
|
110
108
|
|
@@ -114,7 +112,7 @@ module Vips
|
|
114
112
|
|
115
113
|
image = block.(image)
|
116
114
|
|
117
|
-
|
115
|
+
unless Image::complex? original_format
|
118
116
|
new_format = image.format == :dpcomplex ? :double : :float
|
119
117
|
image = image.copy format: new_format, bands: image.bands * 2
|
120
118
|
end
|
@@ -324,17 +322,17 @@ module Vips
|
|
324
322
|
def self.new_from_array array, scale = 1, offset = 0
|
325
323
|
# we accept a 1D array and assume height == 1, or a 2D array
|
326
324
|
# and check all lines are the same length
|
327
|
-
|
325
|
+
unless array.is_a? Array
|
328
326
|
raise Vips::Error, "Argument is not an array."
|
329
327
|
end
|
330
328
|
|
331
329
|
if array[0].is_a? Array
|
332
330
|
height = array.length
|
333
331
|
width = array[0].length
|
334
|
-
|
332
|
+
unless array.all? {|x| x.is_a? Array}
|
335
333
|
raise Vips::Error, "Not a 2D array."
|
336
334
|
end
|
337
|
-
|
335
|
+
unless array.all? {|x| x.length == width}
|
338
336
|
raise Vips::Error, "Array not rectangular."
|
339
337
|
end
|
340
338
|
array = array.flatten
|
@@ -343,7 +341,7 @@ module Vips
|
|
343
341
|
width = array.length
|
344
342
|
end
|
345
343
|
|
346
|
-
|
344
|
+
unless array.all? {|x| x.is_a? Numeric}
|
347
345
|
raise Vips::Error, "Not all array elements are Numeric."
|
348
346
|
end
|
349
347
|
|
@@ -477,7 +475,7 @@ module Vips
|
|
477
475
|
def get_typeof name
|
478
476
|
# on libvips before 8.5, property types must be searched first,
|
479
477
|
# since vips_image_get_typeof returned built-in enums as int
|
480
|
-
|
478
|
+
unless Vips::at_least_libvips?(8, 5)
|
481
479
|
gtype = parent_get_typeof name
|
482
480
|
return gtype if gtype != 0
|
483
481
|
end
|
@@ -501,7 +499,7 @@ module Vips
|
|
501
499
|
def get name
|
502
500
|
# with old libvips, we must fetch properties (as opposed to
|
503
501
|
# metadata) via VipsObject
|
504
|
-
|
502
|
+
unless Vips::at_least_libvips?(8, 5)
|
505
503
|
return super if parent_get_typeof(name) != 0
|
506
504
|
end
|
507
505
|
|
@@ -518,7 +516,7 @@ module Vips
|
|
518
516
|
# @return [[String]] array of field names
|
519
517
|
def get_fields
|
520
518
|
# vips_image_get_fields() was added in libvips 8.5
|
521
|
-
return []
|
519
|
+
return [] unless Vips.respond_to? :vips_image_get_fields
|
522
520
|
|
523
521
|
array = Vips::vips_image_get_fields self
|
524
522
|
|
@@ -885,8 +883,7 @@ module Vips
|
|
885
883
|
# @return [Image] extracted band(s)
|
886
884
|
def [] index
|
887
885
|
if index.is_a? Range
|
888
|
-
n = index.
|
889
|
-
n += 1 if not index.exclude_end?
|
886
|
+
n = index.size
|
890
887
|
extract_band index.begin, n: n
|
891
888
|
elsif index.is_a? Numeric
|
892
889
|
extract_band index
|
@@ -921,12 +918,10 @@ module Vips
|
|
921
918
|
array = memory.unpack(template)
|
922
919
|
|
923
920
|
# gather band elements together
|
924
|
-
pixel_array =
|
925
|
-
array.each_slice(bands) {|pixel| pixel_array << pixel}
|
921
|
+
pixel_array = array.each_slice(bands).to_a
|
926
922
|
|
927
923
|
# build rows
|
928
|
-
row_array =
|
929
|
-
pixel_array.each_slice(width) {|row| row_array << row}
|
924
|
+
row_array = pixel_array.each_slice(width).to_a
|
930
925
|
|
931
926
|
return row_array
|
932
927
|
end
|
@@ -977,7 +972,7 @@ module Vips
|
|
977
972
|
#
|
978
973
|
# @return [Array<Image>] Array of n one-band images
|
979
974
|
def bandsplit
|
980
|
-
(0...bands).map {|i| extract_band
|
975
|
+
(0...bands).map {|i| extract_band i}
|
981
976
|
end
|
982
977
|
|
983
978
|
# Join a set of images bandwise.
|
@@ -985,20 +980,39 @@ module Vips
|
|
985
980
|
# @param other [Image, Array<Image>, Real, Array<Real>] bands to append
|
986
981
|
# @return [Image] many band image
|
987
982
|
def bandjoin other
|
988
|
-
|
983
|
+
unless other.is_a? Array
|
989
984
|
other = [other]
|
990
985
|
end
|
991
986
|
|
992
987
|
# if other is just Numeric, we can use bandjoin_const
|
993
|
-
not_all_real =
|
988
|
+
not_all_real = !other.all?{|x| x.is_a? Numeric}
|
994
989
|
|
995
990
|
if not_all_real
|
996
991
|
Vips::Image.bandjoin([self] + other)
|
997
992
|
else
|
998
|
-
bandjoin_const
|
993
|
+
bandjoin_const other
|
999
994
|
end
|
1000
995
|
end
|
1001
996
|
|
997
|
+
# Composite a set of images with a set of blend modes.
|
998
|
+
#
|
999
|
+
# @param other [Image, Array<Image>, Real, Array<Real>] bands to append
|
1000
|
+
# @return [Image] many band image
|
1001
|
+
def composite other, mode, opts = {}
|
1002
|
+
unless other.is_a? Array
|
1003
|
+
other = [other]
|
1004
|
+
end
|
1005
|
+
unless mode.is_a? Array
|
1006
|
+
mode = [mode]
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
mode = mode.map do |x|
|
1010
|
+
GObject::GValue.from_nick Vips::BLEND_MODE_TYPE, x
|
1011
|
+
end
|
1012
|
+
|
1013
|
+
Vips::Image.composite([self] + other, mode, opts)
|
1014
|
+
end
|
1015
|
+
|
1002
1016
|
# Return the coordinates of the image maximum.
|
1003
1017
|
#
|
1004
1018
|
# @return [Real, Real, Real] maximum value, x coordinate of maximum, y
|
@@ -1244,10 +1258,10 @@ module Vips
|
|
1244
1258
|
def ifthenelse(th, el, opts = {})
|
1245
1259
|
match_image = [th, el, self].find {|x| x.is_a? Vips::Image}
|
1246
1260
|
|
1247
|
-
|
1261
|
+
unless th.is_a? Vips::Image
|
1248
1262
|
th = Operation.imageize match_image, th
|
1249
1263
|
end
|
1250
|
-
|
1264
|
+
unless el.is_a? Vips::Image
|
1251
1265
|
el = Operation.imageize match_image, el
|
1252
1266
|
end
|
1253
1267
|
|
@@ -1278,7 +1292,7 @@ module Vips
|
|
1278
1292
|
|
1279
1293
|
def self.generate_yard
|
1280
1294
|
# these have hand-written methods, see above
|
1281
|
-
no_generate = ["scale", "bandjoin", "ifthenelse"]
|
1295
|
+
no_generate = ["scale", "bandjoin", "composite", "ifthenelse"]
|
1282
1296
|
|
1283
1297
|
# map gobject's type names to Ruby
|
1284
1298
|
map_go_to_ruby = {
|
@@ -1312,7 +1326,7 @@ module Vips
|
|
1312
1326
|
next if (arg_flags & ARGUMENT_CONSTRUCT) == 0
|
1313
1327
|
next if (arg_flags & ARGUMENT_DEPRECATED) != 0
|
1314
1328
|
|
1315
|
-
name = pspec[:name].
|
1329
|
+
name = pspec[:name].tr("-", "_")
|
1316
1330
|
# 'in' as a param name confuses yard
|
1317
1331
|
name = "im" if name == "in"
|
1318
1332
|
gtype = pspec[:value_type]
|
@@ -1321,10 +1335,9 @@ module Vips
|
|
1321
1335
|
if map_go_to_ruby.include? type_name
|
1322
1336
|
type_name = map_go_to_ruby[type_name]
|
1323
1337
|
end
|
1324
|
-
if fundamental == GObject::GFLAGS_TYPE
|
1338
|
+
if fundamental == GObject::GFLAGS_TYPE ||
|
1325
1339
|
fundamental == GObject::GENUM_TYPE
|
1326
|
-
type_name
|
1327
|
-
type_name = "Vips::" + $~[1]
|
1340
|
+
type_name = "Vips::" + type_name[/Vips(.*)/, 1]
|
1328
1341
|
end
|
1329
1342
|
blurb = GObject::g_param_spec_get_blurb pspec
|
1330
1343
|
value = {:name => name,
|
@@ -1337,7 +1350,7 @@ module Vips
|
|
1337
1350
|
if (arg_flags & ARGUMENT_REQUIRED) != 0
|
1338
1351
|
# note the first required input image, if any ... we
|
1339
1352
|
# will be a method of this instance
|
1340
|
-
if
|
1353
|
+
if !member_x && gtype == Vips::IMAGE_TYPE
|
1341
1354
|
member_x = value
|
1342
1355
|
else
|
1343
1356
|
required_input << value
|
@@ -1348,10 +1361,10 @@ module Vips
|
|
1348
1361
|
end
|
1349
1362
|
|
1350
1363
|
# MODIFY INPUT args count as OUTPUT as well
|
1351
|
-
if (arg_flags & ARGUMENT_OUTPUT) != 0
|
1352
|
-
((arg_flags & ARGUMENT_INPUT) != 0
|
1364
|
+
if (arg_flags & ARGUMENT_OUTPUT) != 0 ||
|
1365
|
+
((arg_flags & ARGUMENT_INPUT) != 0 &&
|
1353
1366
|
(arg_flags & ARGUMENT_MODIFY) != 0)
|
1354
|
-
if (arg_flags & ARGUMENT_REQUIRED) != 0
|
1367
|
+
if (arg_flags & ARGUMENT_REQUIRED) != 0
|
1355
1368
|
required_output << value
|
1356
1369
|
else
|
1357
1370
|
optional_output << value
|
@@ -1361,7 +1374,7 @@ module Vips
|
|
1361
1374
|
end
|
1362
1375
|
|
1363
1376
|
print "# @!method "
|
1364
|
-
print "self."
|
1377
|
+
print "self." unless member_x
|
1365
1378
|
print "#{nickname}("
|
1366
1379
|
print required_input.map{|x| x[:name]}.join(", ")
|
1367
1380
|
print ", " if required_input.length > 0
|
data/lib/vips/object.rb
CHANGED
@@ -32,6 +32,13 @@ module Vips
|
|
32
32
|
INTERPRETATION_TYPE = Vips::vips_interpretation_get_type
|
33
33
|
CODING_TYPE = Vips::vips_coding_get_type
|
34
34
|
|
35
|
+
if Vips::at_least_libvips?(8, 6)
|
36
|
+
attach_function :vips_blend_mode_get_type, [], :GType
|
37
|
+
BLEND_MODE_TYPE = Vips::vips_blend_mode_get_type
|
38
|
+
else
|
39
|
+
BLEND_MODE_TYPE = nil
|
40
|
+
end
|
41
|
+
|
35
42
|
private
|
36
43
|
|
37
44
|
attach_function :vips_enum_from_nick, [:string, :GType, :string], :int
|
@@ -125,7 +132,7 @@ module Vips
|
|
125
132
|
# return a gtype, raise an error on not found
|
126
133
|
def get_typeof_error name
|
127
134
|
pspec = get_pspec name
|
128
|
-
raise Vips::Error
|
135
|
+
raise Vips::Error unless pspec
|
129
136
|
|
130
137
|
pspec[:value][:value_type]
|
131
138
|
end
|
@@ -133,7 +140,7 @@ module Vips
|
|
133
140
|
# return a gtype, 0 on not found
|
134
141
|
def get_typeof name
|
135
142
|
pspec = get_pspec name
|
136
|
-
|
143
|
+
unless pspec
|
137
144
|
Vips::vips_error_clear
|
138
145
|
return 0
|
139
146
|
end
|
data/lib/vips/operation.rb
CHANGED
@@ -98,7 +98,7 @@ module Vips
|
|
98
98
|
if (flags & ARGUMENT_CONSTRUCT) != 0
|
99
99
|
# names can include - as punctuation, but we always use _ in
|
100
100
|
# Ruby
|
101
|
-
name = pspec[:name].
|
101
|
+
name = pspec[:name].tr("-", "_")
|
102
102
|
|
103
103
|
args << [name, flags]
|
104
104
|
end
|
@@ -125,7 +125,8 @@ module Vips
|
|
125
125
|
|
126
126
|
# 2D array values become tiny 2D images
|
127
127
|
# if there's nothing to match to, we also make a 2D image
|
128
|
-
if (value.is_a?
|
128
|
+
if (value.is_a?(Array) && value[0].is_a?(Array)) ||
|
129
|
+
match_image == nil
|
129
130
|
return Image.new_from_array value
|
130
131
|
else
|
131
132
|
# we have a 1D array ... use that as a pixel constant and
|
@@ -240,7 +241,7 @@ module Vips
|
|
240
241
|
next if (flags & ARGUMENT_DEPRECATED) != 0
|
241
242
|
|
242
243
|
if (flags & ARGUMENT_INPUT) != 0
|
243
|
-
if (flags & ARGUMENT_REQUIRED) != 0
|
244
|
+
if (flags & ARGUMENT_REQUIRED) != 0
|
244
245
|
required_input << [name, flags]
|
245
246
|
else
|
246
247
|
optional_input[name] = flags
|
@@ -248,10 +249,10 @@ module Vips
|
|
248
249
|
end
|
249
250
|
|
250
251
|
# MODIFY INPUT args count as OUTPUT as well
|
251
|
-
if (flags & ARGUMENT_OUTPUT) != 0
|
252
|
-
((flags & ARGUMENT_INPUT) != 0
|
252
|
+
if (flags & ARGUMENT_OUTPUT) != 0 ||
|
253
|
+
((flags & ARGUMENT_INPUT) != 0 &&
|
253
254
|
(flags & ARGUMENT_MODIFY) != 0)
|
254
|
-
if (flags & ARGUMENT_REQUIRED) != 0
|
255
|
+
if (flags & ARGUMENT_REQUIRED) != 0
|
255
256
|
required_output << [name, flags]
|
256
257
|
else
|
257
258
|
optional_output[name] = flags
|
@@ -262,11 +263,11 @@ module Vips
|
|
262
263
|
|
263
264
|
# so we should have been supplied with n_required_input values, or
|
264
265
|
# n_required_input + 1 if there's a hash of options at the end
|
265
|
-
|
266
|
+
unless supplied.is_a? Array
|
266
267
|
raise Vips::Error, "unable to call #{name}: " +
|
267
268
|
"argument array is not an array"
|
268
269
|
end
|
269
|
-
|
270
|
+
unless optional.is_a? Hash
|
270
271
|
raise Vips::Error, "unable to call #{name}: " +
|
271
272
|
"optional arguments are not a hash"
|
272
273
|
end
|
@@ -281,8 +282,8 @@ module Vips
|
|
281
282
|
optional.each do |key, value|
|
282
283
|
arg_name = key.to_s
|
283
284
|
|
284
|
-
|
285
|
-
|
285
|
+
unless optional_input.has_key?(arg_name) ||
|
286
|
+
optional_output.has_key?(arg_name)
|
286
287
|
raise Vips::Error, "unable to call #{name}: " +
|
287
288
|
"unknown option #{arg_name}"
|
288
289
|
end
|
data/lib/vips/version.rb
CHANGED
data/ruby-vips.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_development_dependency "rake", ["~> 11.0"]
|
32
32
|
spec.add_development_dependency "rspec", ["~> 3.3"]
|
33
|
-
spec.add_development_dependency "yard", ["~> 0.
|
33
|
+
spec.add_development_dependency "yard", ["~> 0.9.11"]
|
34
34
|
spec.add_development_dependency "redcarpet", ["~> 3.3"]
|
35
35
|
spec.add_development_dependency "github-markup", ["~> 1.4"]
|
36
36
|
spec.add_development_dependency "bundler", ["~> 1.0"]
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Cupitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.9.11
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.9.11
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: redcarpet
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- example/example4.rb
|
137
137
|
- example/example5.rb
|
138
138
|
- example/inheritance_with_refcount.rb
|
139
|
+
- example/thumb.rb
|
139
140
|
- example/trim8.rb
|
140
141
|
- example/watermark.rb
|
141
142
|
- example/wobble.rb
|