ruby-vips 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/VERSION +1 -1
- data/lib/vips.rb +13 -36
- data/lib/vips/image.rb +31 -10
- data/lib/vips/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 614489c8022d27d06892f9980c0df0cca00d7598
|
4
|
+
data.tar.gz: 9c0332039d753a99a4eb526f6b424d6a432c4b6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9f73109c2116d56f607e9cee9a01b8bce41d380b223f0e734576a4066184cab9162e514759fcbf36750c6adc30df86467ed1755b9904b6469c66063efee1542
|
7
|
+
data.tar.gz: 12f7e4f9e3af5ead044a1fd9e46a2e080f0e612b34216fe26966c734501dd2633a66417a25144644b96e00440970345939e591503ca660fa76837b6ff365f85d
|
data/CHANGELOG.md
CHANGED
@@ -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.
|
1
|
+
1.0.6
|
data/lib/vips.rb
CHANGED
@@ -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
|
45
|
-
log "Vips::
|
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
|
data/lib/vips/image.rb
CHANGED
@@ -982,19 +982,40 @@ module Vips
|
|
982
982
|
end
|
983
983
|
end
|
984
984
|
|
985
|
-
# Convert to an Array. This will be
|
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
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
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.
|
data/lib/vips/version.rb
CHANGED