vips 8.6.3.2 → 8.8.2
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/.travis.yml +27 -22
- data/CHANGELOG.md +273 -0
- data/example/annotate.rb +2 -2
- data/example/daltonize8.rb +26 -28
- data/example/example1.rb +1 -2
- data/example/example2.rb +6 -6
- data/example/example3.rb +5 -5
- data/example/example4.rb +6 -6
- data/example/example5.rb +6 -7
- data/example/inheritance_with_refcount.rb +201 -218
- data/example/thumb.rb +10 -12
- data/example/trim8.rb +6 -6
- data/example/watermark.rb +14 -35
- data/example/wobble.rb +24 -24
- data/lib/vips.rb +335 -312
- data/lib/vips/access.rb +9 -9
- data/lib/vips/align.rb +7 -8
- data/lib/vips/angle.rb +8 -9
- data/lib/vips/angle45.rb +12 -13
- data/lib/vips/bandformat.rb +16 -18
- data/lib/vips/blend_mode.rb +32 -0
- data/lib/vips/coding.rb +11 -12
- data/lib/vips/compass_direction.rb +13 -14
- data/lib/vips/direction.rb +7 -8
- data/lib/vips/extend.rb +13 -14
- data/lib/vips/gobject.rb +92 -96
- data/lib/vips/gvalue.rb +231 -237
- data/lib/vips/image.rb +1329 -1330
- data/lib/vips/interesting.rb +10 -11
- data/lib/vips/interpolate.rb +49 -54
- data/lib/vips/interpretation.rb +25 -26
- data/lib/vips/kernel.rb +18 -19
- data/lib/vips/methods.rb +2319 -2141
- data/lib/vips/object.rb +204 -213
- data/lib/vips/operation.rb +317 -323
- data/lib/vips/operationboolean.rb +10 -11
- data/lib/vips/operationcomplex.rb +8 -9
- data/lib/vips/operationcomplex2.rb +6 -7
- data/lib/vips/operationcomplexget.rb +7 -8
- data/lib/vips/operationmath.rb +14 -15
- data/lib/vips/operationmath2.rb +6 -7
- data/lib/vips/operationrelational.rb +11 -12
- data/lib/vips/operationround.rb +7 -8
- data/lib/vips/size.rb +9 -10
- data/lib/vips/version.rb +1 -1
- data/vips.gemspec +1 -1
- metadata +9 -8
data/example/example1.rb
CHANGED
data/example/example2.rb
CHANGED
@@ -17,12 +17,12 @@ Vips::cache_set_max 0
|
|
17
17
|
n = 10000
|
18
18
|
|
19
19
|
n.times do |i|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
puts ""
|
21
|
+
puts "call #{i} ..."
|
22
|
+
out = Vips::Operation.call "black", [200, 300]
|
23
|
+
if out.width != 200 or out.height != 300
|
24
|
+
puts "bad image result from black"
|
25
|
+
end
|
26
26
|
end
|
27
27
|
|
28
28
|
puts ""
|
data/example/example3.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'vips'
|
4
4
|
|
5
|
-
# this makes vips keep a list of all active objects
|
5
|
+
# this makes vips keep a list of all active objects
|
6
6
|
Vips::leak_set true
|
7
7
|
|
8
8
|
# disable the operation cache
|
@@ -12,8 +12,8 @@ Vips::leak_set true
|
|
12
12
|
GLib::logger.level = Logger::DEBUG
|
13
13
|
|
14
14
|
1.times do |i|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
puts "loop #{i} ..."
|
16
|
+
im = Vips::Image.new_from_file ARGV[0]
|
17
|
+
im = im.embed 100, 100, 3000, 3000, :extend => :mirror
|
18
|
+
im.write_to_file "x.v"
|
19
19
|
end
|
data/example/example4.rb
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
require 'vips'
|
4
4
|
|
5
|
-
# this makes vips keep a list of all active objects
|
5
|
+
# this makes vips keep a list of all active objects
|
6
6
|
Vips::leak_set true
|
7
7
|
|
8
8
|
# disable the operation cache
|
9
|
-
#Vips::cache_set_max 0
|
9
|
+
# Vips::cache_set_max 0
|
10
10
|
|
11
11
|
# turn on debug logging
|
12
|
-
#Vips.set_debug true
|
12
|
+
# Vips.set_debug true
|
13
13
|
|
14
14
|
ARGV.each do |filename|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
im = Vips::Image.new_from_file filename
|
16
|
+
profile = im.get_value "icc-profile-data"
|
17
|
+
puts "profile has #{profile.length} bytes"
|
18
18
|
end
|
data/example/example5.rb
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
require 'vips'
|
4
4
|
|
5
|
-
# this makes vips keep a list of all active objects
|
5
|
+
# this makes vips keep a list of all active objects
|
6
6
|
# Vips::leak_set true
|
7
7
|
|
8
8
|
# disable the operation cache
|
9
9
|
# Vips::cache_set_max 0
|
10
10
|
|
11
11
|
# turn on debug logging
|
12
|
-
#Vips.set_debug true
|
12
|
+
# Vips.set_debug true
|
13
13
|
|
14
14
|
if ARGV.length < 2
|
15
|
-
|
15
|
+
raise "usage: #{$PROGRAM_NAME}: input-file output-file"
|
16
16
|
end
|
17
17
|
|
18
18
|
im = Vips::Image.new_from_file ARGV[0], :access => :sequential
|
@@ -22,10 +22,9 @@ im *= [1, 2, 1]
|
|
22
22
|
# we want to be able to specify a scale for the convolution mask, so we have to
|
23
23
|
# make it ourselves
|
24
24
|
# if you are OK with scale=1, you can just pass the array directly to .conv()
|
25
|
-
mask = Vips::Image.new_from_array [
|
26
|
-
|
27
|
-
|
28
|
-
[-1, -1, -1]], 8
|
25
|
+
mask = Vips::Image.new_from_array [[-1, -1, -1],
|
26
|
+
[-1, 16, -1],
|
27
|
+
[-1, -1, -1]], 8
|
29
28
|
im = im.conv mask
|
30
29
|
|
31
30
|
im.write_to_file ARGV[1]
|
@@ -10,277 +10,260 @@ $vips_debug = true
|
|
10
10
|
|
11
11
|
# @private
|
12
12
|
def log str
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
if $vips_debug
|
14
|
+
puts str
|
15
|
+
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def set_debug debug
|
19
|
-
|
19
|
+
$vips_debug = debug
|
20
20
|
end
|
21
21
|
|
22
22
|
module Libc
|
23
|
-
|
24
|
-
|
23
|
+
extend FFI::Library
|
24
|
+
ffi_lib FFI::Library::LIBC
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
attach_function :malloc, [:size_t], :pointer
|
27
|
+
attach_function :free, [:pointer], :void
|
28
28
|
end
|
29
29
|
|
30
30
|
module GLib
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
layout :g_type_instance, :pointer,
|
74
|
-
:ref_count, :uint,
|
75
|
-
:qdata, :pointer
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# the struct with unref ... manage object lifetime with this
|
81
|
-
class ManagedStruct < FFI::ManagedStruct
|
82
|
-
include GObjectLayout
|
83
|
-
|
84
|
-
def initialize(ptr)
|
85
|
-
log "GLib::GObject::ManagedStruct.new: #{ptr}"
|
86
|
-
super
|
87
|
-
end
|
88
|
-
|
89
|
-
def self.release(ptr)
|
90
|
-
log "GLib::GObject::ManagedStruct.release: unreffing #{ptr}"
|
91
|
-
GLib::g_object_unref(ptr) unless ptr.null?
|
92
|
-
end
|
93
|
-
|
31
|
+
extend FFI::Library
|
32
|
+
ffi_lib 'gobject-2.0'
|
33
|
+
|
34
|
+
def self.set_log_domain(_domain)
|
35
|
+
# FIXME: this needs hooking up
|
36
|
+
end
|
37
|
+
|
38
|
+
# we have a set of things we need to inherit in different ways:
|
39
|
+
#
|
40
|
+
# - we want to be able to subclass GObject in a simple way
|
41
|
+
# - the layouts of the nested structs
|
42
|
+
# - casting between structs which share a base
|
43
|
+
# - gobject refcounting
|
44
|
+
#
|
45
|
+
# the solution is to split the class into four areas which we treat
|
46
|
+
# differently:
|
47
|
+
#
|
48
|
+
# - we have a "wrapper" Ruby class to allow easy subclassing ... this has a
|
49
|
+
# @struct member which holds the actual pointer
|
50
|
+
# - we use "forwardable" to forward the various ffi methods on to the
|
51
|
+
# @struct member ... we arrange things so that subclasses do not need to
|
52
|
+
# do the forwarding themselves
|
53
|
+
# - we have two versions of the struct: a plain one which we can use for
|
54
|
+
# casting that will not change the refcounts
|
55
|
+
# - and a managed one with an unref which we just use for .new
|
56
|
+
# - we separate the struct layout into a separate module to avoid repeating
|
57
|
+
# ourselves
|
58
|
+
|
59
|
+
class GObject
|
60
|
+
extend Forwardable
|
61
|
+
extend SingleForwardable
|
62
|
+
|
63
|
+
def_instance_delegators :@struct, :[], :to_ptr
|
64
|
+
def_single_delegators :ffi_struct, :ptr
|
65
|
+
|
66
|
+
# the layout of the GObject struct
|
67
|
+
module GObjectLayout
|
68
|
+
def self.included(base)
|
69
|
+
base.class_eval do
|
70
|
+
layout :g_type_instance, :pointer,
|
71
|
+
:ref_count, :uint,
|
72
|
+
:qdata, :pointer
|
94
73
|
end
|
74
|
+
end
|
75
|
+
end
|
95
76
|
|
96
|
-
|
97
|
-
|
98
|
-
|
77
|
+
# the struct with unref ... manage object lifetime with this
|
78
|
+
class ManagedStruct < FFI::ManagedStruct
|
79
|
+
include GObjectLayout
|
99
80
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
81
|
+
def initialize(ptr)
|
82
|
+
log "GLib::GObject::ManagedStruct.new: #{ptr}"
|
83
|
+
super
|
84
|
+
end
|
104
85
|
|
105
|
-
|
86
|
+
def self.release(ptr)
|
87
|
+
log "GLib::GObject::ManagedStruct.release: unreffing #{ptr}"
|
88
|
+
GLib::g_object_unref(ptr) unless ptr.null?
|
89
|
+
end
|
90
|
+
end
|
106
91
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
# here we use ManagedStruct, not Struct, since this is the ref that will
|
111
|
-
# need the unref
|
112
|
-
def initialize(ptr)
|
113
|
-
log "GLib::GObject.initialize: ptr = #{ptr}"
|
114
|
-
@struct = ffi_managed_struct.new(ptr)
|
115
|
-
end
|
92
|
+
# the plain struct ... cast with this
|
93
|
+
class Struct < FFI::Struct
|
94
|
+
include GObjectLayout
|
116
95
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
96
|
+
def initialize(ptr)
|
97
|
+
log "GLib::GObject::Struct.new: #{ptr}"
|
98
|
+
super
|
99
|
+
end
|
100
|
+
end
|
121
101
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
102
|
+
# don't allow ptr == nil, we never want to allocate a GObject struct
|
103
|
+
# ourselves, we just want to wrap GLib-allocated GObjects
|
104
|
+
#
|
105
|
+
# here we use ManagedStruct, not Struct, since this is the ref that will
|
106
|
+
# need the unref
|
107
|
+
def initialize(ptr)
|
108
|
+
log "GLib::GObject.initialize: ptr = #{ptr}"
|
109
|
+
@struct = ffi_managed_struct.new(ptr)
|
110
|
+
end
|
127
111
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
112
|
+
# access to the cast struct for this class
|
113
|
+
def ffi_struct
|
114
|
+
self.class.ffi_struct
|
115
|
+
end
|
132
116
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
117
|
+
class << self
|
118
|
+
def ffi_struct
|
119
|
+
self.const_get(:Struct)
|
120
|
+
end
|
121
|
+
end
|
138
122
|
|
123
|
+
# access to the lifetime managed struct for this class
|
124
|
+
def ffi_managed_struct
|
125
|
+
self.class.ffi_managed_struct
|
139
126
|
end
|
140
127
|
|
141
|
-
|
142
|
-
|
128
|
+
class << self
|
129
|
+
def ffi_managed_struct
|
130
|
+
self.const_get(:ManagedStruct)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
143
134
|
|
135
|
+
# :gtype will usually be 64-bit, but will be 32-bit on 32-bit Windows
|
136
|
+
typedef :ulong, :GType
|
144
137
|
end
|
145
138
|
|
146
139
|
module Vips
|
147
|
-
|
148
|
-
|
140
|
+
extend FFI::Library
|
141
|
+
ffi_lib 'vips'
|
149
142
|
|
150
|
-
|
151
|
-
|
143
|
+
LOG_DOMAIN = "VIPS"
|
144
|
+
GLib::set_log_domain(LOG_DOMAIN)
|
152
145
|
|
153
|
-
|
154
|
-
|
146
|
+
# need to repeat this
|
147
|
+
typedef :ulong, :GType
|
155
148
|
|
156
|
-
|
157
|
-
|
149
|
+
attach_function :vips_init, [:string], :int
|
150
|
+
attach_function :vips_shutdown, [], :void
|
158
151
|
|
159
|
-
|
160
|
-
|
152
|
+
attach_function :vips_error_buffer, [], :string
|
153
|
+
attach_function :vips_error_clear, [], :void
|
161
154
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
155
|
+
def self.get_error
|
156
|
+
errstr = Vips::vips_error_buffer
|
157
|
+
Vips::vips_error_clear
|
158
|
+
errstr
|
159
|
+
end
|
167
160
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
161
|
+
if Vips::vips_init($0) != 0
|
162
|
+
puts Vips::get_error
|
163
|
+
exit 1
|
164
|
+
end
|
172
165
|
|
173
|
-
|
174
|
-
|
175
|
-
|
166
|
+
at_exit {
|
167
|
+
Vips::vips_shutdown
|
168
|
+
}
|
176
169
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
def self.showall
|
181
|
-
if $vips_debug
|
182
|
-
GC.start
|
183
|
-
vips_object_print_all
|
184
|
-
end
|
185
|
-
end
|
170
|
+
attach_function :vips_object_print_all, [], :void
|
171
|
+
attach_function :vips_leak_set, [:int], :void
|
186
172
|
|
173
|
+
def self.showall
|
187
174
|
if $vips_debug
|
188
|
-
|
175
|
+
GC.start
|
176
|
+
vips_object_print_all
|
189
177
|
end
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
178
|
+
end
|
179
|
+
|
180
|
+
if $vips_debug
|
181
|
+
vips_leak_set 1
|
182
|
+
end
|
183
|
+
|
184
|
+
class VipsObject < GLib::GObject
|
185
|
+
# the layout of the VipsObject struct
|
186
|
+
module VipsObjectLayout
|
187
|
+
def self.included(base)
|
188
|
+
base.class_eval do
|
189
|
+
# don't actually need most of these, remove them later
|
190
|
+
layout :parent, GLib::GObject::Struct,
|
191
|
+
:constructed, :int,
|
192
|
+
:static_object, :int,
|
193
|
+
:argument_table, :pointer,
|
194
|
+
:nickname, :string,
|
195
|
+
:description, :string,
|
196
|
+
:preclose, :int,
|
197
|
+
:close, :int,
|
198
|
+
:postclose, :int,
|
199
|
+
:local_memory, :size_t
|
210
200
|
end
|
211
|
-
|
212
|
-
class Struct < GLib::GObject::Struct
|
213
|
-
include VipsObjectLayout
|
214
|
-
|
215
|
-
def initialize(ptr)
|
216
|
-
log "Vips::VipsObject::Struct.new: #{ptr}"
|
217
|
-
super
|
218
|
-
end
|
219
|
-
|
220
|
-
end
|
221
|
-
|
222
|
-
class ManagedStruct < GLib::GObject::ManagedStruct
|
223
|
-
include VipsObjectLayout
|
224
|
-
|
225
|
-
def initialize(ptr)
|
226
|
-
log "Vips::VipsObject::ManagedStruct.new: #{ptr}"
|
227
|
-
super
|
228
|
-
end
|
229
|
-
|
230
|
-
end
|
231
|
-
|
201
|
+
end
|
232
202
|
end
|
233
203
|
|
234
|
-
class
|
235
|
-
|
236
|
-
# the layout of the VipsImage struct
|
237
|
-
module VipsImageLayout
|
238
|
-
def self.included(base)
|
239
|
-
base.class_eval do
|
240
|
-
layout :parent, VipsObject::Struct
|
241
|
-
# rest opaque
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
204
|
+
class Struct < GLib::GObject::Struct
|
205
|
+
include VipsObjectLayout
|
245
206
|
|
246
|
-
|
247
|
-
|
207
|
+
def initialize(ptr)
|
208
|
+
log "Vips::VipsObject::Struct.new: #{ptr}"
|
209
|
+
super
|
210
|
+
end
|
211
|
+
end
|
248
212
|
|
249
|
-
|
250
|
-
|
251
|
-
super
|
252
|
-
end
|
213
|
+
class ManagedStruct < GLib::GObject::ManagedStruct
|
214
|
+
include VipsObjectLayout
|
253
215
|
|
216
|
+
def initialize(ptr)
|
217
|
+
log "Vips::VipsObject::ManagedStruct.new: #{ptr}"
|
218
|
+
super
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
class VipsImage < VipsObject
|
224
|
+
# the layout of the VipsImage struct
|
225
|
+
module VipsImageLayout
|
226
|
+
def self.included(base)
|
227
|
+
base.class_eval do
|
228
|
+
layout :parent, VipsObject::Struct
|
229
|
+
# rest opaque
|
254
230
|
end
|
231
|
+
end
|
232
|
+
end
|
255
233
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
def initialize(ptr)
|
260
|
-
log "Vips::VipsImage::ManagedStruct.new: #{ptr}"
|
261
|
-
super
|
262
|
-
end
|
234
|
+
class Struct < VipsObject::Struct
|
235
|
+
include VipsImageLayout
|
263
236
|
|
264
|
-
|
237
|
+
def initialize(ptr)
|
238
|
+
log "Vips::VipsImage::Struct.new: #{ptr}"
|
239
|
+
super
|
240
|
+
end
|
241
|
+
end
|
265
242
|
|
266
|
-
|
267
|
-
|
268
|
-
end
|
243
|
+
class ManagedStruct < VipsObject::ManagedStruct
|
244
|
+
include VipsImageLayout
|
269
245
|
|
246
|
+
def initialize(ptr)
|
247
|
+
log "Vips::VipsImage::ManagedStruct.new: #{ptr}"
|
248
|
+
super
|
249
|
+
end
|
270
250
|
end
|
271
251
|
|
272
|
-
|
252
|
+
def self.new_partial
|
253
|
+
VipsImage.new(Vips::vips_image_new)
|
254
|
+
end
|
255
|
+
end
|
273
256
|
|
257
|
+
attach_function :vips_image_new, [], :pointer
|
274
258
|
end
|
275
259
|
|
276
260
|
puts "creating image"
|
277
261
|
begin
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
262
|
+
x = Vips::VipsImage.new_partial
|
263
|
+
puts "x = #{x}"
|
264
|
+
puts ""
|
265
|
+
puts "x[:parent] = #{x[:parent]}"
|
266
|
+
puts ""
|
267
|
+
puts "x[:parent][:description] = #{x[:parent][:description]}"
|
268
|
+
puts ""
|
285
269
|
end
|
286
|
-
|