ruby-vips 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2446e29083185a98ac3bb6188f4aea09e5e0cd4e
4
- data.tar.gz: ef6ef9641798e39418476661573f9227bab6d946
3
+ metadata.gz: 38b222b12b892a0cfbd9532a25e977c14e20ca4b
4
+ data.tar.gz: f21db53783fb278d10c03293b3e356a9b22c5bed
5
5
  SHA512:
6
- metadata.gz: acf05666f8e861380016b9d9e86ec7a3e617964b9c77b72ff5fe284e6c0cbd9f23b9888c5031bc67b522e189047cd6823583fb4bc055b0f73399d286e69f54d5
7
- data.tar.gz: 3d699ef4ba6799dd787d4a534cb8858a4c1ed3aa88237825b390e1c746d7e608f4ed8a9e50a2af18de22b8314cc0074a8afbd4fe83f379fc0b9070c4826beb6b
6
+ metadata.gz: fad99e35598db1433300247d531d4fa6d2fbe82b47ce0ee7d5a9fe1224f28833d83832774db52a8b50de91b65f51e98410eaad7dda55fb76eb1757daa7e3372c
7
+ data.tar.gz: 784a0f8a3e8b4fcea5688b5c72e8b92d8901ea6ce8aa2c3d3453a660c14815871e008ad010333475748ce88b8102ab9b80e8ff308b0631a82ee8b59fe85e6a8b
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## Version 2.0.5 (2017-09-02)
6
+
7
+ * fix get() with older libvipses
8
+
5
9
  ## Version 2.0.4 (2017-09-02)
6
10
 
7
11
  * add a test for `get_fields`, since it appeared in libvips 8.5 (thanks zverok)
data/README.md CHANGED
@@ -51,7 +51,7 @@ which gives some more background.
51
51
  It's just:
52
52
 
53
53
  ```
54
- $ gem install ruby-vips
54
+ $ gem install ruby-vips
55
55
  ```
56
56
 
57
57
  or include it in `Gemfile`:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.4
1
+ 2.0.5
@@ -33,9 +33,7 @@ module Vips
33
33
  # vips_image_get_fields was added in libvips 8.5
34
34
  begin
35
35
  attach_function :vips_image_get_fields, [:pointer], :pointer
36
- HAS_IMAGE_GET_FIELDS = true
37
36
  rescue FFI::NotFoundError
38
- HAS_IMAGE_GET_FIELDS = false
39
37
  end
40
38
 
41
39
  attach_function :vips_image_set,
@@ -475,7 +473,19 @@ module Vips
475
473
  # @param name [String] Metadata field to fetch
476
474
  # @return [Integer] GType
477
475
  def get_typeof name
478
- Vips::vips_image_get_typeof self, name
476
+ # libvips 8.5+ has a fast path for this
477
+ if Vips::version(0) > 8 or Vips::version(1) > 4
478
+ Vips::vips_image_get_typeof self, name
479
+ else
480
+ # with older libvips, we have to look in properties first, then
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
488
+ end
479
489
  end
480
490
 
481
491
  # Get a metadata item from an image. Ruby types are constructed
@@ -492,6 +502,16 @@ module Vips
492
502
  # @param name [String] Metadata field to get
493
503
  # @return [Object] Value of field
494
504
  def get name
505
+ # with old libvips, we must fetch properties (as opposed to
506
+ # metadata) via VipsObject
507
+ unless Vips::version(0) > 8 or Vips::version(1) > 4
508
+ gtype = get_typeof_property name
509
+ if gtype != 0
510
+ # found a property
511
+ return super
512
+ end
513
+ end
514
+
495
515
  gvalue = GObject::GValue.alloc
496
516
  result = Vips::vips_image_get self, name, gvalue
497
517
  if result != 0
@@ -507,7 +527,7 @@ module Vips
507
527
  # @return [[String]] array of field names
508
528
  def get_fields
509
529
  # vips_image_get_fields() was added in libvips 8.5
510
- if not Vips::HAS_IMAGE_GET_FIELDS
530
+ if not Vips.respond_to? :vips_image_get_fields
511
531
  return []
512
532
  end
513
533
 
@@ -108,20 +108,24 @@ module Vips
108
108
 
109
109
  end
110
110
 
111
- def get_typeof name
111
+ def get_typeof_property name
112
112
  pspec = GObject::GParamSpecPtr.new
113
113
  argument_class = Vips::ArgumentClassPtr.new
114
114
  argument_instance = Vips::ArgumentInstancePtr.new
115
115
 
116
116
  result = Vips::vips_object_get_argument self, name,
117
117
  pspec, argument_class, argument_instance
118
- raise Vips::Error if result != 0
118
+ return 0 if result != 0
119
119
 
120
120
  pspec[:value][:value_type]
121
121
  end
122
122
 
123
+ def get_typeof name
124
+ get_typeof_property name
125
+ end
126
+
123
127
  def get name
124
- gtype = get_typeof name
128
+ gtype = get_typeof_property name
125
129
  gvalue = GObject::GValue.alloc
126
130
  gvalue.init gtype
127
131
  GObject::g_object_get_property self, name, gvalue
@@ -135,7 +139,7 @@ module Vips
135
139
  def set name, value
136
140
  GLib::logger.debug("Vips::Object.set") {"#{name} = #{value}"}
137
141
 
138
- gtype = get_typeof name
142
+ gtype = get_typeof_property name
139
143
  gvalue = GObject::GValue.alloc
140
144
  gvalue.init gtype
141
145
  gvalue.set value
@@ -1,4 +1,4 @@
1
1
  module Vips
2
- VERSION = "2.0.4"
2
+ VERSION = "2.0.5"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-vips
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Cupitt