ruby-vips 2.0.13 → 2.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -0
- data/.rubocop_todo.yml +730 -0
- data/.travis.yml +13 -6
- data/CHANGELOG.md +8 -0
- data/README.md +5 -8
- data/Rakefile +6 -0
- data/VERSION +1 -1
- data/example/annotate.rb +2 -2
- data/example/daltonize8.rb +14 -14
- data/example/example2.rb +6 -6
- data/example/example3.rb +5 -5
- data/example/example4.rb +4 -4
- data/example/example5.rb +2 -2
- data/example/inheritance_with_refcount.rb +207 -207
- data/example/thumb.rb +10 -10
- data/example/trim8.rb +2 -2
- data/example/watermark.rb +14 -35
- data/example/wobble.rb +24 -24
- data/install-vips.sh +1 -1
- data/lib/vips.rb +335 -306
- data/lib/vips/access.rb +9 -9
- data/lib/vips/align.rb +7 -7
- data/lib/vips/angle.rb +8 -8
- data/lib/vips/angle45.rb +12 -12
- data/lib/vips/bandformat.rb +16 -16
- data/lib/vips/blend_mode.rb +34 -0
- data/lib/vips/coding.rb +11 -11
- data/lib/vips/compass_direction.rb +13 -13
- data/lib/vips/direction.rb +7 -7
- data/lib/vips/extend.rb +13 -13
- data/lib/vips/gobject.rb +94 -94
- data/lib/vips/gvalue.rb +232 -232
- data/lib/vips/image.rb +1329 -1335
- data/lib/vips/interesting.rb +10 -10
- data/lib/vips/interpolate.rb +51 -51
- data/lib/vips/interpretation.rb +25 -25
- data/lib/vips/kernel.rb +18 -18
- data/lib/vips/methods.rb +463 -283
- data/lib/vips/object.rb +208 -208
- data/lib/vips/operation.rb +323 -323
- data/lib/vips/operationboolean.rb +10 -10
- data/lib/vips/operationcomplex.rb +8 -8
- data/lib/vips/operationcomplex2.rb +6 -6
- data/lib/vips/operationcomplexget.rb +7 -7
- data/lib/vips/operationmath.rb +14 -14
- data/lib/vips/operationmath2.rb +6 -6
- data/lib/vips/operationrelational.rb +11 -11
- data/lib/vips/operationround.rb +7 -7
- data/lib/vips/size.rb +9 -9
- data/lib/vips/version.rb +1 -1
- data/ruby-vips.gemspec +6 -2
- metadata +29 -6
data/.travis.yml
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
dist:
|
2
|
-
sudo: false
|
1
|
+
dist: xenial
|
3
2
|
|
4
3
|
env:
|
5
4
|
global:
|
6
5
|
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
7
6
|
- VIPS_VERSION_MAJOR=8
|
8
|
-
- VIPS_VERSION_MINOR=
|
9
|
-
- VIPS_VERSION_MICRO=
|
7
|
+
- VIPS_VERSION_MINOR=7
|
8
|
+
- VIPS_VERSION_MICRO=2
|
10
9
|
- PATH=$HOME/vips/bin:$PATH
|
11
10
|
- LD_LIBRARY_PATH=$HOME/vips/lib:$LD_LIBRARY_PATH
|
12
11
|
- PKG_CONFIG_PATH=$HOME/vips/lib/pkgconfig:$PKG_CONFIG_PATH
|
@@ -33,6 +32,7 @@ addons:
|
|
33
32
|
- libwebp-dev
|
34
33
|
|
35
34
|
cache:
|
35
|
+
bundler: true
|
36
36
|
directories:
|
37
37
|
- $HOME/vips
|
38
38
|
|
@@ -44,12 +44,19 @@ rvm:
|
|
44
44
|
- 2.3
|
45
45
|
- 2.4
|
46
46
|
- 2.5
|
47
|
+
- 2.6
|
47
48
|
|
48
|
-
script:
|
49
|
+
script: bundle exec rake spec
|
49
50
|
|
50
51
|
gemfile:
|
51
52
|
- Gemfile
|
52
53
|
|
53
54
|
before_install:
|
54
55
|
- uname -a
|
55
|
-
- bash install-vips.sh
|
56
|
+
- bash install-vips.sh
|
57
|
+
|
58
|
+
jobs:
|
59
|
+
include:
|
60
|
+
- stage: Lint
|
61
|
+
rvm: 2.6
|
62
|
+
script: bundle exec rake rubocop
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## Version 2.0.14 (2018-10-3)
|
6
|
+
|
7
|
+
* update links for new home [jcupitt]
|
8
|
+
* various doc fixes [janko-m]
|
9
|
+
* add `Vips::get_suffixes` [jcupitt]
|
10
|
+
* prefer options splat [ioquatix]
|
11
|
+
* update docs for 8.8 [jcupitt]
|
12
|
+
|
5
13
|
## Version 2.0.13 (2018-8-6)
|
6
14
|
|
7
15
|
* allow optional args to have `nil` as a value [janko-m]
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# ruby-vips
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/ruby-vips.svg)](https://badge.fury.io/rb/ruby-vips)
|
4
|
-
[![Build Status](https://travis-ci.org/
|
4
|
+
[![Build Status](https://travis-ci.org/libvips/ruby-vips.svg?branch=master)](https://travis-ci.org/libvips/ruby-vips)
|
5
5
|
|
6
6
|
This gem provides a Ruby binding for the [libvips image processing
|
7
|
-
library](https://
|
7
|
+
library](https://libvips.github.io/libvips).
|
8
8
|
|
9
9
|
Programs that use `ruby-vips` don't
|
10
10
|
manipulate images directly, instead they create pipelines of image processing
|
@@ -31,16 +31,13 @@ rmagick.rb 788768
|
|
31
31
|
```
|
32
32
|
|
33
33
|
See also [benchmarks at the official libvips
|
34
|
-
website](https://github.com/
|
35
|
-
There's a handy blog post explaining [how libvips opens
|
36
|
-
files](http://libvips.blogspot.co.uk/2012/06/how-libvips-opens-file.html)
|
37
|
-
which gives some more background.
|
34
|
+
website](https://github.com/libvips/libvips/wiki/Speed-and-memory-use).
|
38
35
|
|
39
36
|
## Requirements
|
40
37
|
|
41
38
|
* macOS, Linux, and Windows tested
|
42
39
|
|
43
|
-
* libvips 8.2 or later, see the [libvips install instructions](https://
|
40
|
+
* libvips 8.2 or later, see the [libvips install instructions](https://libvips.github.io/libvips/install.html)
|
44
41
|
|
45
42
|
* [ruby-ffi](https://github.com/ffi/ffi) 1.9 or later
|
46
43
|
|
@@ -76,7 +73,7 @@ im = Vips::Image.new_from_file filename
|
|
76
73
|
# put im at position (100, 100) in a 3000 x 3000 pixel image,
|
77
74
|
# make the other pixels in the image by mirroring im up / down /
|
78
75
|
# left / right, see
|
79
|
-
# https://
|
76
|
+
# https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-embed
|
80
77
|
im = im.embed 100, 100, 3000, 3000, extend: :mirror
|
81
78
|
|
82
79
|
# multiply the green (middle) band by 2, leave the other two alone
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.14
|
data/example/annotate.rb
CHANGED
@@ -5,13 +5,13 @@ require 'vips'
|
|
5
5
|
im = Vips::Image.new_from_file ARGV[0], :access => :sequential
|
6
6
|
|
7
7
|
left_text = Vips::Image.text "left corner", :dpi => 300
|
8
|
-
left = left_text.embed 50, 50, im.width, 150
|
8
|
+
left = left_text.embed 50, 50, im.width, 150
|
9
9
|
|
10
10
|
right_text = Vips::Image.text "right corner", :dpi => 300
|
11
11
|
right = right_text.embed im.width - right_text.width - 50, 50, im.width, 150
|
12
12
|
|
13
13
|
footer = (left | right).ifthenelse(0, [255, 0, 0], :blend => true)
|
14
14
|
|
15
|
-
im = im.insert footer, 0, im.height, :expand => true
|
15
|
+
im = im.insert footer, 0, im.height, :expand => true
|
16
16
|
|
17
17
|
im.write_to_file ARGV[1]
|
data/example/daltonize8.rb
CHANGED
@@ -28,20 +28,20 @@ im = Vips::Image.new_from_file ARGV[0]
|
|
28
28
|
# remove any alpha channel before processing
|
29
29
|
alpha = nil
|
30
30
|
if im.bands == 4
|
31
|
-
|
32
|
-
|
31
|
+
alpha = im[3]
|
32
|
+
im = im.extract_band 0, :n => 3
|
33
33
|
end
|
34
34
|
|
35
35
|
begin
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
# import to XYZ with lcms
|
37
|
+
# if there's no profile there, we'll fall back to the thing below
|
38
|
+
xyz = im.icc_import :embedded => true, :pcs => :xyz
|
39
39
|
rescue Vips::Error
|
40
|
-
|
41
|
-
|
40
|
+
# nope .. use the built-in converter instead
|
41
|
+
xyz = im.colourspace :xyz
|
42
42
|
end
|
43
43
|
|
44
|
-
brad = xyz.recomb xyz_to_brad
|
44
|
+
brad = xyz.recomb xyz_to_brad
|
45
45
|
|
46
46
|
# through the Deuteranope matrix
|
47
47
|
# we need rows to sum to 1 in Bradford space --- the matrix in the original
|
@@ -52,24 +52,24 @@ deut = brad.recomb [
|
|
52
52
|
[0, 0, 1]
|
53
53
|
]
|
54
54
|
|
55
|
-
xyz = deut.recomb brad_to_xyz
|
55
|
+
xyz = deut.recomb brad_to_xyz
|
56
56
|
|
57
|
-
# .. and back to sRGB
|
57
|
+
# .. and back to sRGB
|
58
58
|
rgb = xyz.colourspace :srgb
|
59
59
|
|
60
|
-
# so this is the colour error
|
60
|
+
# so this is the colour error
|
61
61
|
err = im - rgb
|
62
62
|
|
63
63
|
# add the error back to other channels to make a compensated image
|
64
64
|
im = im + err.recomb([
|
65
|
-
[0, 0, 0],
|
65
|
+
[0, 0, 0],
|
66
66
|
[0.7, 1, 0],
|
67
67
|
[0.7, 0, 1]
|
68
68
|
])
|
69
69
|
|
70
70
|
# reattach any alpha we saved above
|
71
71
|
if alpha
|
72
|
-
|
72
|
+
im = im.bandjoin(alpha)
|
73
73
|
end
|
74
74
|
|
75
|
-
im.write_to_file ARGV[1]
|
75
|
+
im.write_to_file ARGV[1]
|
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,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,7 +12,7 @@ Vips::leak_set true
|
|
12
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,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,7 +12,7 @@ require 'vips'
|
|
12
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
|
@@ -10,277 +10,277 @@ $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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
31
|
+
extend FFI::Library
|
32
|
+
ffi_lib 'gobject-2.0'
|
33
|
+
|
34
|
+
# nil being the default
|
35
|
+
glib_log_domain = nil
|
36
|
+
|
37
|
+
def self.set_log_domain(domain)
|
38
|
+
glib_log_domain = domain
|
39
|
+
end
|
40
|
+
|
41
|
+
# we have a set of things we need to inherit in different ways:
|
42
|
+
#
|
43
|
+
# - we want to be able to subclass GObject in a simple way
|
44
|
+
# - the layouts of the nested structs
|
45
|
+
# - casting between structs which share a base
|
46
|
+
# - gobject refcounting
|
47
|
+
#
|
48
|
+
# the solution is to split the class into four areas which we treat
|
49
|
+
# differently:
|
50
|
+
#
|
51
|
+
# - we have a "wrapper" Ruby class to allow easy subclassing ... this has a
|
52
|
+
# @struct member which holds the actual pointer
|
53
|
+
# - we use "forwardable" to forward the various ffi methods on to the
|
54
|
+
# @struct member ... we arrange things so that subclasses do not need to
|
55
|
+
# do the forwarding themselves
|
56
|
+
# - we have two versions of the struct: a plain one which we can use for
|
57
|
+
# casting that will not change the refcounts
|
58
|
+
# - and a managed one with an unref which we just use for .new
|
59
|
+
# - we separate the struct layout into a separate module to avoid repeating
|
60
|
+
# ourselves
|
61
|
+
|
62
|
+
class GObject
|
63
|
+
extend Forwardable
|
64
|
+
extend SingleForwardable
|
65
|
+
|
66
|
+
def_instance_delegators :@struct, :[], :to_ptr
|
67
|
+
def_single_delegators :ffi_struct, :ptr
|
68
|
+
|
69
|
+
# the layout of the GObject struct
|
70
|
+
module GObjectLayout
|
71
|
+
def self.included(base)
|
72
|
+
base.class_eval do
|
73
|
+
layout :g_type_instance, :pointer,
|
74
|
+
:ref_count, :uint,
|
75
|
+
:qdata, :pointer
|
78
76
|
end
|
77
|
+
end
|
78
|
+
end
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
def initialize(ptr)
|
85
|
-
log "GLib::GObject::ManagedStruct.new: #{ptr}"
|
86
|
-
super
|
87
|
-
end
|
80
|
+
# the struct with unref ... manage object lifetime with this
|
81
|
+
class ManagedStruct < FFI::ManagedStruct
|
82
|
+
include GObjectLayout
|
88
83
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
84
|
+
def initialize(ptr)
|
85
|
+
log "GLib::GObject::ManagedStruct.new: #{ptr}"
|
86
|
+
super
|
87
|
+
end
|
93
88
|
|
94
|
-
|
89
|
+
def self.release(ptr)
|
90
|
+
log "GLib::GObject::ManagedStruct.release: unreffing #{ptr}"
|
91
|
+
GLib::g_object_unref(ptr) unless ptr.null?
|
92
|
+
end
|
95
93
|
|
96
|
-
|
97
|
-
class Struct < FFI::Struct
|
98
|
-
include GObjectLayout
|
94
|
+
end
|
99
95
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
96
|
+
# the plain struct ... cast with this
|
97
|
+
class Struct < FFI::Struct
|
98
|
+
include GObjectLayout
|
104
99
|
|
105
|
-
|
100
|
+
def initialize(ptr)
|
101
|
+
log "GLib::GObject::Struct.new: #{ptr}"
|
102
|
+
super
|
103
|
+
end
|
106
104
|
|
107
|
-
|
108
|
-
# ourselves, we just want to wrap GLib-allocated GObjects
|
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
|
105
|
+
end
|
116
106
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
107
|
+
# don't allow ptr == nil, we never want to allocate a GObject struct
|
108
|
+
# ourselves, we just want to wrap GLib-allocated GObjects
|
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
|
121
116
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
end
|
117
|
+
# access to the cast struct for this class
|
118
|
+
def ffi_struct
|
119
|
+
self.class.ffi_struct
|
120
|
+
end
|
127
121
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
122
|
+
class << self
|
123
|
+
def ffi_struct
|
124
|
+
self.const_get(:Struct)
|
125
|
+
end
|
126
|
+
end
|
132
127
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
end
|
128
|
+
# access to the lifetime managed struct for this class
|
129
|
+
def ffi_managed_struct
|
130
|
+
self.class.ffi_managed_struct
|
131
|
+
end
|
138
132
|
|
133
|
+
class << self
|
134
|
+
def ffi_managed_struct
|
135
|
+
self.const_get(:ManagedStruct)
|
136
|
+
end
|
139
137
|
end
|
140
138
|
|
141
|
-
|
142
|
-
|
139
|
+
end
|
140
|
+
|
141
|
+
# :gtype will usually be 64-bit, but will be 32-bit on 32-bit Windows
|
142
|
+
typedef :ulong, :GType
|
143
143
|
|
144
144
|
end
|
145
145
|
|
146
146
|
module Vips
|
147
|
-
|
148
|
-
|
147
|
+
extend FFI::Library
|
148
|
+
ffi_lib 'vips'
|
149
149
|
|
150
|
-
|
151
|
-
|
150
|
+
LOG_DOMAIN = "VIPS"
|
151
|
+
GLib::set_log_domain(LOG_DOMAIN)
|
152
152
|
|
153
|
-
|
154
|
-
|
153
|
+
# need to repeat this
|
154
|
+
typedef :ulong, :GType
|
155
155
|
|
156
|
-
|
157
|
-
|
156
|
+
attach_function :vips_init, [:string], :int
|
157
|
+
attach_function :vips_shutdown, [], :void
|
158
158
|
|
159
|
-
|
160
|
-
|
159
|
+
attach_function :vips_error_buffer, [], :string
|
160
|
+
attach_function :vips_error_clear, [], :void
|
161
161
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
if Vips::vips_init($0) != 0
|
169
|
-
puts Vips::get_error
|
170
|
-
exit 1
|
171
|
-
end
|
162
|
+
def self.get_error
|
163
|
+
errstr = Vips::vips_error_buffer
|
164
|
+
Vips::vips_error_clear
|
165
|
+
errstr
|
166
|
+
end
|
172
167
|
|
173
|
-
|
174
|
-
|
175
|
-
|
168
|
+
if Vips::vips_init($0) != 0
|
169
|
+
puts Vips::get_error
|
170
|
+
exit 1
|
171
|
+
end
|
176
172
|
|
177
|
-
|
178
|
-
|
173
|
+
at_exit {
|
174
|
+
Vips::vips_shutdown
|
175
|
+
}
|
179
176
|
|
180
|
-
|
181
|
-
|
182
|
-
GC.start
|
183
|
-
vips_object_print_all
|
184
|
-
end
|
185
|
-
end
|
177
|
+
attach_function :vips_object_print_all, [], :void
|
178
|
+
attach_function :vips_leak_set, [:int], :void
|
186
179
|
|
180
|
+
def self.showall
|
187
181
|
if $vips_debug
|
188
|
-
|
182
|
+
GC.start
|
183
|
+
vips_object_print_all
|
189
184
|
end
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
185
|
+
end
|
186
|
+
|
187
|
+
if $vips_debug
|
188
|
+
vips_leak_set 1
|
189
|
+
end
|
190
|
+
|
191
|
+
class VipsObject < GLib::GObject
|
192
|
+
|
193
|
+
# the layout of the VipsObject struct
|
194
|
+
module VipsObjectLayout
|
195
|
+
def self.included(base)
|
196
|
+
base.class_eval do
|
197
|
+
# don't actually need most of these, remove them later
|
198
|
+
layout :parent, GLib::GObject::Struct,
|
199
|
+
:constructed, :int,
|
200
|
+
:static_object, :int,
|
201
|
+
:argument_table, :pointer,
|
202
|
+
:nickname, :string,
|
203
|
+
:description, :string,
|
204
|
+
:preclose, :int,
|
205
|
+
:close, :int,
|
206
|
+
:postclose, :int,
|
207
|
+
:local_memory, :size_t
|
210
208
|
end
|
209
|
+
end
|
210
|
+
end
|
211
211
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
def initialize(ptr)
|
216
|
-
log "Vips::VipsObject::Struct.new: #{ptr}"
|
217
|
-
super
|
218
|
-
end
|
212
|
+
class Struct < GLib::GObject::Struct
|
213
|
+
include VipsObjectLayout
|
219
214
|
|
220
|
-
|
215
|
+
def initialize(ptr)
|
216
|
+
log "Vips::VipsObject::Struct.new: #{ptr}"
|
217
|
+
super
|
218
|
+
end
|
221
219
|
|
222
|
-
|
223
|
-
include VipsObjectLayout
|
220
|
+
end
|
224
221
|
|
225
|
-
|
226
|
-
|
227
|
-
super
|
228
|
-
end
|
222
|
+
class ManagedStruct < GLib::GObject::ManagedStruct
|
223
|
+
include VipsObjectLayout
|
229
224
|
|
230
|
-
|
225
|
+
def initialize(ptr)
|
226
|
+
log "Vips::VipsObject::ManagedStruct.new: #{ptr}"
|
227
|
+
super
|
228
|
+
end
|
231
229
|
|
232
230
|
end
|
233
231
|
|
234
|
-
|
232
|
+
end
|
235
233
|
|
236
|
-
|
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
|
234
|
+
class VipsImage < VipsObject
|
245
235
|
|
246
|
-
|
247
|
-
|
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
|
248
245
|
|
249
|
-
|
250
|
-
|
251
|
-
super
|
252
|
-
end
|
246
|
+
class Struct < VipsObject::Struct
|
247
|
+
include VipsImageLayout
|
253
248
|
|
254
|
-
|
249
|
+
def initialize(ptr)
|
250
|
+
log "Vips::VipsImage::Struct.new: #{ptr}"
|
251
|
+
super
|
252
|
+
end
|
255
253
|
|
256
|
-
|
257
|
-
include VipsImageLayout
|
254
|
+
end
|
258
255
|
|
259
|
-
|
260
|
-
|
261
|
-
super
|
262
|
-
end
|
256
|
+
class ManagedStruct < VipsObject::ManagedStruct
|
257
|
+
include VipsImageLayout
|
263
258
|
|
264
|
-
|
259
|
+
def initialize(ptr)
|
260
|
+
log "Vips::VipsImage::ManagedStruct.new: #{ptr}"
|
261
|
+
super
|
262
|
+
end
|
265
263
|
|
266
|
-
|
267
|
-
VipsImage.new(Vips::vips_image_new)
|
268
|
-
end
|
264
|
+
end
|
269
265
|
|
266
|
+
def self.new_partial
|
267
|
+
VipsImage.new(Vips::vips_image_new)
|
270
268
|
end
|
271
269
|
|
272
|
-
|
270
|
+
end
|
271
|
+
|
272
|
+
attach_function :vips_image_new, [], :pointer
|
273
273
|
|
274
274
|
end
|
275
275
|
|
276
276
|
puts "creating image"
|
277
277
|
begin
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
278
|
+
x = Vips::VipsImage.new_partial
|
279
|
+
puts "x = #{x}"
|
280
|
+
puts ""
|
281
|
+
puts "x[:parent] = #{x[:parent]}"
|
282
|
+
puts ""
|
283
|
+
puts "x[:parent][:description] = #{x[:parent][:description]}"
|
284
|
+
puts ""
|
285
285
|
end
|
286
286
|
|