ruby-vips 2.0.5 → 2.0.6
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/CHANGELOG.md +4 -0
- data/VERSION +1 -1
- data/example/wobble.rb +2 -2
- data/lib/vips.rb +8 -0
- data/lib/vips/image.rb +13 -24
- data/lib/vips/object.rb +22 -5
- data/lib/vips/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 977fd4194df253aca0b38025de9dcf563e9050fb
|
4
|
+
data.tar.gz: 6f675830bc3809d3e9b73656607ebc688d8e2cb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee2eed6adc45832a11c316b136076df8b6a0d7032b9d96cde61ef2fbd21829022e84f8a9b290df432bd36369914f58d92e2edb4c136f3f96fe4d1c1aeb5ec636
|
7
|
+
data.tar.gz: dc22e1b1fdec424250c77f7a08953d5a77c085e116ee875f29cbba8f71d98b1649199f5c7b6d41bb7fa8aef101be187fec55683d3df43d0b19e358e8e04b2bcc
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.6
|
data/example/wobble.rb
CHANGED
@@ -8,8 +8,8 @@ module Vips
|
|
8
8
|
class Image
|
9
9
|
def wobble
|
10
10
|
# this makes an image where pixel (0, 0) (at the top-left) has
|
11
|
-
# value [0, 0], and pixel (image.width, image.height) at the
|
12
|
-
# bottom-right has value [image.width, image.height]
|
11
|
+
# value [0, 0], and pixel (image.width - 1, image.height - 1) at the
|
12
|
+
# bottom-right has value [image.width - 1, image.height - 1]
|
13
13
|
index = Vips::Image.xyz width, height
|
14
14
|
|
15
15
|
# make a version with (0, 0) at the centre, negative values up
|
data/lib/vips.rb
CHANGED
@@ -546,6 +546,14 @@ module Vips
|
|
546
546
|
attach_function :version, :vips_version, [:int], :int
|
547
547
|
attach_function :version_string, :vips_version_string, [], :string
|
548
548
|
|
549
|
+
# True if this is at least libvips x.y
|
550
|
+
def self.at_least_libvips?(x, y)
|
551
|
+
major = version(0)
|
552
|
+
minor = version(1)
|
553
|
+
|
554
|
+
major > x or (major == x and minor >= y)
|
555
|
+
end
|
556
|
+
|
549
557
|
LIBRARY_VERSION = Vips::version_string
|
550
558
|
|
551
559
|
end
|
data/lib/vips/image.rb
CHANGED
@@ -51,6 +51,8 @@ module Vips
|
|
51
51
|
# for an introduction to using this class.
|
52
52
|
|
53
53
|
class Image < Vips::Object
|
54
|
+
alias_method :parent_get_typeof, :get_typeof
|
55
|
+
|
54
56
|
private
|
55
57
|
|
56
58
|
# the layout of the VipsImage struct
|
@@ -473,19 +475,14 @@ module Vips
|
|
473
475
|
# @param name [String] Metadata field to fetch
|
474
476
|
# @return [Integer] GType
|
475
477
|
def get_typeof name
|
476
|
-
# libvips 8.5
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
# fall back to metadata
|
482
|
-
gtype = get_typeof_property name
|
483
|
-
if gtype != 0
|
484
|
-
gtype
|
485
|
-
else
|
486
|
-
Vips::vips_image_get_typeof self, name
|
487
|
-
end
|
478
|
+
# on libvips before 8.5, property types must be searched first,
|
479
|
+
# since vips_image_get_typeof returned built-in enums as int
|
480
|
+
if not Vips::at_least_libvips?(8, 5)
|
481
|
+
gtype = parent_get_typeof name
|
482
|
+
return gtype if gtype != 0
|
488
483
|
end
|
484
|
+
|
485
|
+
Vips::vips_image_get_typeof self, name
|
489
486
|
end
|
490
487
|
|
491
488
|
# Get a metadata item from an image. Ruby types are constructed
|
@@ -504,19 +501,13 @@ module Vips
|
|
504
501
|
def get name
|
505
502
|
# with old libvips, we must fetch properties (as opposed to
|
506
503
|
# metadata) via VipsObject
|
507
|
-
|
508
|
-
|
509
|
-
if gtype != 0
|
510
|
-
# found a property
|
511
|
-
return super
|
512
|
-
end
|
504
|
+
if not Vips::at_least_libvips?(8, 5)
|
505
|
+
return super if parent_get_typeof(name) != 0
|
513
506
|
end
|
514
507
|
|
515
508
|
gvalue = GObject::GValue.alloc
|
516
509
|
result = Vips::vips_image_get self, name, gvalue
|
517
|
-
if result != 0
|
518
|
-
raise Vips::Error
|
519
|
-
end
|
510
|
+
raise Vips::Error if result != 0
|
520
511
|
|
521
512
|
return gvalue.get
|
522
513
|
end
|
@@ -527,9 +518,7 @@ module Vips
|
|
527
518
|
# @return [[String]] array of field names
|
528
519
|
def get_fields
|
529
520
|
# vips_image_get_fields() was added in libvips 8.5
|
530
|
-
if not Vips.respond_to? :vips_image_get_fields
|
531
|
-
return []
|
532
|
-
end
|
521
|
+
return [] if not Vips.respond_to? :vips_image_get_fields
|
533
522
|
|
534
523
|
array = Vips::vips_image_get_fields self
|
535
524
|
|
data/lib/vips/object.rb
CHANGED
@@ -108,24 +108,41 @@ module Vips
|
|
108
108
|
|
109
109
|
end
|
110
110
|
|
111
|
-
|
111
|
+
# return a pspec, or nil ... nil wil leave a message in the error log
|
112
|
+
# which you must clear
|
113
|
+
def get_pspec name
|
112
114
|
pspec = GObject::GParamSpecPtr.new
|
113
115
|
argument_class = Vips::ArgumentClassPtr.new
|
114
116
|
argument_instance = Vips::ArgumentInstancePtr.new
|
115
117
|
|
116
118
|
result = Vips::vips_object_get_argument self, name,
|
117
119
|
pspec, argument_class, argument_instance
|
118
|
-
return
|
120
|
+
return nil if result != 0
|
121
|
+
|
122
|
+
pspec
|
123
|
+
end
|
124
|
+
|
125
|
+
# return a gtype, raise an error on not found
|
126
|
+
def get_typeof_error name
|
127
|
+
pspec = get_pspec name
|
128
|
+
raise Vips::Error if not pspec
|
119
129
|
|
120
130
|
pspec[:value][:value_type]
|
121
131
|
end
|
122
132
|
|
133
|
+
# return a gtype, 0 on not found
|
123
134
|
def get_typeof name
|
124
|
-
|
135
|
+
pspec = get_pspec name
|
136
|
+
if not pspec
|
137
|
+
Vips::vips_error_clear
|
138
|
+
return 0
|
139
|
+
end
|
140
|
+
|
141
|
+
pspec[:value][:value_type]
|
125
142
|
end
|
126
143
|
|
127
144
|
def get name
|
128
|
-
gtype =
|
145
|
+
gtype = get_typeof_error name
|
129
146
|
gvalue = GObject::GValue.alloc
|
130
147
|
gvalue.init gtype
|
131
148
|
GObject::g_object_get_property self, name, gvalue
|
@@ -139,7 +156,7 @@ module Vips
|
|
139
156
|
def set name, value
|
140
157
|
GLib::logger.debug("Vips::Object.set") {"#{name} = #{value}"}
|
141
158
|
|
142
|
-
gtype =
|
159
|
+
gtype = get_typeof_error name
|
143
160
|
gvalue = GObject::GValue.alloc
|
144
161
|
gvalue.init gtype
|
145
162
|
gvalue.set value
|
data/lib/vips/version.rb
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.6
|
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-09-
|
11
|
+
date: 2017-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|