ruby-vips 1.0.5 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa7ceeea5a7f3ba540d67ff5940b75229c55195b
4
- data.tar.gz: 15ab5c034633a329a591b7db148ab5f2de294442
3
+ metadata.gz: 614489c8022d27d06892f9980c0df0cca00d7598
4
+ data.tar.gz: 9c0332039d753a99a4eb526f6b424d6a432c4b6b
5
5
  SHA512:
6
- metadata.gz: 7a5f515a544a0a09cd68b4faafe23b5e10d06207855826e5a1a09cf0791a1ebf28ba5f2282a1bdc2301aaa21bab39e160c7a11bb76fbbf36370d7551b0b47f45
7
- data.tar.gz: d483450c4931f687a7b219890f0ce49ada8f4a56334718b0c123a60a8cafc27aa3c45d5085cb4c2dd394e3bec037b10ac54e3fc595ea8250ca5188bd2a8030a5
6
+ metadata.gz: c9f73109c2116d56f607e9cee9a01b8bce41d380b223f0e734576a4066184cab9162e514759fcbf36750c6adc30df86467ed1755b9904b6469c66063efee1542
7
+ data.tar.gz: 12f7e4f9e3af5ead044a1fd9e46a2e080f0e612b34216fe26966c734501dd2633a66417a25144644b96e00440970345939e591503ca660fa76837b6ff365f85d
@@ -1,5 +1,11 @@
1
1
  # master
2
2
 
3
+ # Version 1.0.6
4
+
5
+ * remove lazy load, fixing a race with fork() [felixbuenemann]
6
+ * make `Image#to_a` much faster [John Cupitt]
7
+ * remove the `at_exit` handler [John Cupitt]
8
+
3
9
  # Version 1.0.5
4
10
 
5
11
  * fix `_const` for libvips 8.5 [John Cupitt]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.6
@@ -32,6 +32,9 @@ module Vips
32
32
  # about as crude as you could get
33
33
  $vips_debug = false
34
34
 
35
+ # allow to skip GI autoload
36
+ $vips_skip_autoload ||= false
37
+
35
38
  # Turn debug logging on and off.
36
39
  #
37
40
  # @param dbg [Boolean] Set true to print debug log messages
@@ -41,38 +44,8 @@ module Vips
41
44
 
42
45
  class << self
43
46
  # @private
44
- def const_missing(name)
45
- log "Vips::const_missing: #{name}"
46
-
47
- init()
48
- if const_defined?(name)
49
- const_get(name)
50
- else
51
- super
52
- end
53
- end
54
-
55
- # @private
56
- def method_missing(name, *args, &block)
57
- log "Vips::method_missing: #{name}, #{args}, #{block}"
58
-
59
- init()
60
- if respond_to?(name)
61
- __send__(name, *args, &block)
62
- else
63
- super
64
- end
65
- end
66
-
67
- # @private
68
- def init(*argv)
69
- log "Vips::init: #{argv}"
70
-
71
- class << self
72
- remove_method(:init)
73
- remove_method(:const_missing)
74
- remove_method(:method_missing)
75
- end
47
+ def load_gi_module(*argv)
48
+ log "Vips::load_gi_module: #{argv}"
76
49
 
77
50
  loader = Loader.new(self, argv)
78
51
  begin
@@ -92,6 +65,11 @@ module Vips
92
65
  require 'vips/call'
93
66
  require 'vips/image'
94
67
  require 'vips/version'
68
+
69
+ # Make sure we only get called once.
70
+ def self.load_gi_module; false; end
71
+
72
+ true
95
73
  end
96
74
  end
97
75
 
@@ -139,13 +117,12 @@ module Vips
139
117
  end
140
118
  end
141
119
 
142
- at_exit {
143
- Vips::shutdown if Vips.respond_to? :shutdown
144
- }
145
-
146
120
  # this makes vips keep a list of all active objects which we can print out
147
121
  Vips::leak_set true if $vips_debug
148
122
 
123
+ # Initialize GI
124
+ Vips::load_gi_module unless $vips_skip_autoload
125
+
149
126
  # @private
150
127
  def showall
151
128
  if $vips_debug
@@ -982,19 +982,40 @@ module Vips
982
982
  end
983
983
  end
984
984
 
985
- # Convert to an Array. This will be very slow for large images.
985
+ # Convert to an Array. This will be slow for large images.
986
986
  #
987
987
  # @return [Array] array of Fixnum
988
988
  def to_a
989
- ar = Array.new(height)
990
- for y in 0...height
991
- ar[y] = Array.new(width)
992
- for x in 0...width
993
- ar[y][x] = getpoint(x, y)
994
- end
995
- end
996
-
997
- return ar
989
+ # we render the image to a big string, then unpack
990
+ # as a Ruby array of the correct type
991
+ memory = write_to_memory.pack('c*')
992
+
993
+ # make the template for unpack
994
+ template = {
995
+ :char => 'c',
996
+ :uchar => 'C',
997
+ :short => 's_',
998
+ :ushort => 'S_',
999
+ :int => 'i_',
1000
+ :uint => 'I_',
1001
+ :float => 'f',
1002
+ :double => 'd',
1003
+ :complex => 'f',
1004
+ :dpcomplex => 'd'
1005
+ }[format.nick.to_sym] + '*'
1006
+
1007
+ # and unpack into something like [1, 2, 3, 4 ..]
1008
+ array = memory.unpack(template)
1009
+
1010
+ # gather band elements together
1011
+ pixel_array = []
1012
+ array.each_slice(bands) {|pixel| pixel_array << pixel}
1013
+
1014
+ # build rows
1015
+ row_array = []
1016
+ pixel_array.each_slice(width) {|row| row_array << row}
1017
+
1018
+ return row_array
998
1019
  end
999
1020
 
1000
1021
  # Return the largest integral value not greater than the argument.
@@ -1,4 +1,4 @@
1
1
  module Vips
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
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: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Cupitt