ruby-vips 0.3.0 → 0.3.1
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.
- data/CHANGELOG.md +9 -0
- data/README.md +17 -3
- data/ext/ruby_vips.h +8 -0
- data/lib/vips.rb +1 -1
- data/lib/vips/reader.rb +24 -10
- data/lib/vips/version.rb +1 -1
- data/lib/vips/writer.rb +28 -5
- data/ruby-vips.gemspec +3 -3
- metadata +84 -77
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# master
|
2
2
|
|
3
|
+
# Version 0.3.1
|
4
|
+
|
5
|
+
### Fixed
|
6
|
+
|
7
|
+
* PNG writer no longer changes the filename argument [John Cupitt]
|
8
|
+
* Workaround helps ruby-vips compile against 7.26.3 [John Cupitt]
|
9
|
+
* Image read now runs GC and retries on fail [John Cupitt]
|
10
|
+
* Image write GCs every 100 images [John Cupitt]
|
11
|
+
|
3
12
|
# Version 0.3.0
|
4
13
|
|
5
14
|
Release date: 2012-07-20
|
data/README.md
CHANGED
@@ -36,11 +36,15 @@ manipulate, and pass around Image objects without incurring any memory or CPU
|
|
36
36
|
costs. The image is not actually processed until you write the image to memory
|
37
37
|
or to disk.
|
38
38
|
|
39
|
+
*note*: ruby-vips will work with versions of libvips as far back as 7.12, but
|
40
|
+
with missing features and with reduced performance. For best results, use the
|
41
|
+
latest libvips you can.
|
42
|
+
|
39
43
|
## Requirements.
|
40
44
|
|
41
45
|
* OS X or Linux
|
42
46
|
* MRI 1.8.7, 1.9.2
|
43
|
-
* libvips 7.
|
47
|
+
* libvips 7.24 and later (it will work with earlier libvips, but some
|
44
48
|
features may not be functional)
|
45
49
|
|
46
50
|
## Installation.
|
@@ -54,9 +58,19 @@ $ apt-get install libvips-dev
|
|
54
58
|
### OS X Prerequisites.
|
55
59
|
|
56
60
|
```bash
|
57
|
-
$ brew install vips
|
61
|
+
$ brew install --use-llvm vips
|
58
62
|
```
|
59
63
|
|
64
|
+
You may need to set your PKG_CONFIG_PATH before vips can see your libpng. Try
|
65
|
+
something like:
|
66
|
+
|
67
|
+
```bash
|
68
|
+
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/X11/lib/pkgconfig
|
69
|
+
```
|
70
|
+
|
71
|
+
See the Mac OS X Lion section in [Installation on various
|
72
|
+
platforms](https://github.com/jcupitt/ruby-vips/wiki/installation-on-various-platforms).
|
73
|
+
|
60
74
|
TODO: Describe & test with macports.
|
61
75
|
|
62
76
|
### Other platforms
|
@@ -159,6 +173,6 @@ We suggest you schedule a GC every 100 images processed.
|
|
159
173
|
## Why use ruby-vips?
|
160
174
|
|
161
175
|
- It supports over 250 low-level image and color manipulation operations.
|
162
|
-
- Operations are chainable
|
176
|
+
- Operations are chainable and do not get executed until the image is sent to an output.
|
163
177
|
- Memory use is low, even for very, very large images.
|
164
178
|
- Fastest ruby library for resizing large images. See [benchmarks at the official libvips website](http://www.vips.ecs.soton.ac.uk/index.php?title=Speed_and_Memory_Use) and [vips-benchmarks](https://github.com/stanislaw/vips-benchmarks)
|
data/ext/ruby_vips.h
CHANGED
@@ -28,6 +28,14 @@ void vips_lib_error();
|
|
28
28
|
#define rb_str_new_cstr(str) rb_str_new(str, (long)strlen(str))
|
29
29
|
#endif
|
30
30
|
|
31
|
+
/* vips-7.26.3 and earlier 7.26 (used on Ubuntu 12.04) has a broken compat
|
32
|
+
* macro for im_openout(). Make sure we have the correct one defined.
|
33
|
+
*/
|
34
|
+
#ifdef im_openout
|
35
|
+
#undef im_openout
|
36
|
+
#define im_openout( F ) vips_image_new_mode( F, "w" )
|
37
|
+
#endif /*im_openout*/
|
38
|
+
|
31
39
|
#include "header.h"
|
32
40
|
#include "image_arithmetic.h"
|
33
41
|
#include "image_boolean.h"
|
data/lib/vips.rb
CHANGED
data/lib/vips/reader.rb
CHANGED
@@ -10,7 +10,7 @@ module VIPS
|
|
10
10
|
def read
|
11
11
|
# in case the sub-class has not read it
|
12
12
|
if not @_im
|
13
|
-
@_im =
|
13
|
+
@_im = read_retry @path, 0
|
14
14
|
end
|
15
15
|
@_im
|
16
16
|
end
|
@@ -23,6 +23,21 @@ module VIPS
|
|
23
23
|
def y_size
|
24
24
|
@_im.y_size
|
25
25
|
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# read can fail due to no file descriptors ... if we fail, do a GC and try
|
30
|
+
# again a second time
|
31
|
+
def read_retry(path, seq)
|
32
|
+
im = nil
|
33
|
+
begin
|
34
|
+
im = read_internal path, seq
|
35
|
+
rescue
|
36
|
+
GC.start
|
37
|
+
im = read_internal path, seq
|
38
|
+
end
|
39
|
+
im
|
40
|
+
end
|
26
41
|
end
|
27
42
|
|
28
43
|
class JPEGReader < Reader
|
@@ -47,13 +62,13 @@ module VIPS
|
|
47
62
|
str << "fail" if @fail_on_warn
|
48
63
|
|
49
64
|
seq = 0
|
50
|
-
if
|
65
|
+
if VIPS.sequential_mode_supported?
|
51
66
|
str << ","
|
52
67
|
str << "sequential" if @sequential
|
53
68
|
seq = 1
|
54
69
|
end
|
55
70
|
|
56
|
-
@_im =
|
71
|
+
@_im = read_retry str, seq
|
57
72
|
end
|
58
73
|
|
59
74
|
# Shrink the jpeg while reading from disk. This means that the entire image
|
@@ -89,7 +104,7 @@ module VIPS
|
|
89
104
|
# VIPS magic open path limitation/bug -- we cannot specify the comma char
|
90
105
|
str << ",sep:#{@separator}" unless @separator[/,/]
|
91
106
|
|
92
|
-
@_im =
|
107
|
+
@_im = read_retry str, 0
|
93
108
|
end
|
94
109
|
|
95
110
|
# Set the number of lines to skip at the beginning of the file.
|
@@ -129,13 +144,13 @@ module VIPS
|
|
129
144
|
str << "#{@page_number}" if @page_number
|
130
145
|
|
131
146
|
seq = 0
|
132
|
-
if
|
147
|
+
if VIPS.sequential_mode_supported?
|
133
148
|
str << ","
|
134
149
|
str << "sequential" if @sequential
|
135
150
|
seq = 1
|
136
151
|
end
|
137
152
|
|
138
|
-
@_im =
|
153
|
+
@_im = read_retry str, seq
|
139
154
|
end
|
140
155
|
|
141
156
|
# Select which page in a multiple-page tiff to read. When set to nil, all
|
@@ -160,16 +175,15 @@ module VIPS
|
|
160
175
|
end
|
161
176
|
|
162
177
|
def read
|
163
|
-
str = @path
|
178
|
+
str = "#{@path}:"
|
164
179
|
|
165
180
|
seq = 0
|
166
|
-
if
|
167
|
-
str << ":"
|
181
|
+
if VIPS.sequential_mode_supported?
|
168
182
|
str << "sequential" if @sequential
|
169
183
|
seq = 1
|
170
184
|
end
|
171
185
|
|
172
|
-
@_im =
|
186
|
+
@_im = read_retry str, seq
|
173
187
|
end
|
174
188
|
end
|
175
189
|
|
data/lib/vips/version.rb
CHANGED
data/lib/vips/writer.rb
CHANGED
@@ -1,6 +1,29 @@
|
|
1
1
|
module VIPS
|
2
2
|
class Writer
|
3
3
|
def write(path)
|
4
|
+
write_gc path
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
# write can fail due to no file descriptors
|
10
|
+
#
|
11
|
+
# we can't try a write and GC and retry on fail, since the write may take a
|
12
|
+
# long time
|
13
|
+
#
|
14
|
+
# GCing before every write would have a horrible effect on performance, so
|
15
|
+
# as a compromise we GC every @@gc_interval writes
|
16
|
+
|
17
|
+
@@gc_interval = 100
|
18
|
+
@@gc_countdown = @@gc_interval
|
19
|
+
|
20
|
+
def write_gc(path)
|
21
|
+
@@gc_countdown -= 1
|
22
|
+
if @@gc_countdown < 0
|
23
|
+
@@gc_countdown = @@gc_interval
|
24
|
+
GC.start
|
25
|
+
end
|
26
|
+
|
4
27
|
write_internal path
|
5
28
|
end
|
6
29
|
end
|
@@ -16,7 +39,7 @@ module VIPS
|
|
16
39
|
end
|
17
40
|
|
18
41
|
def write(path)
|
19
|
-
|
42
|
+
write_gc "#{path}:sep:#{@separator}"
|
20
43
|
end
|
21
44
|
end
|
22
45
|
|
@@ -32,7 +55,7 @@ module VIPS
|
|
32
55
|
end
|
33
56
|
|
34
57
|
def write(path)
|
35
|
-
|
58
|
+
write_gc "#{path}:#{@quality}"
|
36
59
|
end
|
37
60
|
|
38
61
|
def to_memory
|
@@ -63,7 +86,7 @@ module VIPS
|
|
63
86
|
end
|
64
87
|
|
65
88
|
def write(path)
|
66
|
-
|
89
|
+
write_gc "#{path}:#{@compression},#{@interlace ? 1 : 0}"
|
67
90
|
end
|
68
91
|
|
69
92
|
def to_memory
|
@@ -93,7 +116,7 @@ module VIPS
|
|
93
116
|
end
|
94
117
|
|
95
118
|
def write(path)
|
96
|
-
|
119
|
+
write_gc "#{path}:#{@format}"
|
97
120
|
end
|
98
121
|
|
99
122
|
def format=(format_v)
|
@@ -136,7 +159,7 @@ module VIPS
|
|
136
159
|
|
137
160
|
def write(path)
|
138
161
|
opts = [compression_str, layout_str, @multi_res, @format, resolution_str].join ','
|
139
|
-
|
162
|
+
write_gc "#{path}:#{opts}"
|
140
163
|
end
|
141
164
|
|
142
165
|
def compression_str
|
data/ruby-vips.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "ruby-vips"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Timothy Elliott", "John Cupitt"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-08-30"
|
13
13
|
s.description = "Ruby extension for the vips image processing library."
|
14
14
|
s.email = "jcupitt@gmail.com"
|
15
15
|
s.extensions = ["ext/extconf.rb"]
|
@@ -69,7 +69,7 @@ Gem::Specification.new do |s|
|
|
69
69
|
s.homepage = "http://github.com/jcupitt/ruby-vips"
|
70
70
|
s.licenses = ["MIT"]
|
71
71
|
s.require_paths = ["lib"]
|
72
|
-
s.rubygems_version = "1.8.
|
72
|
+
s.rubygems_version = "1.8.15"
|
73
73
|
s.summary = "ruby-vips is a ruby extension for vips. It is extremely fast and it can process huge images without requiring the entire image to be loaded into memory."
|
74
74
|
|
75
75
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,91 +1,93 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-vips
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Timothy Elliott
|
9
14
|
- John Cupitt
|
10
15
|
autorequire:
|
11
16
|
bindir: bin
|
12
17
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
|
19
|
+
date: 2012-08-30 00:00:00 Z
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
18
23
|
none: false
|
19
|
-
requirements:
|
24
|
+
requirements:
|
20
25
|
- - ~>
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
|
23
|
-
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 31
|
28
|
+
segments:
|
29
|
+
- 3
|
30
|
+
- 12
|
31
|
+
version: "3.12"
|
32
|
+
name: rdoc
|
24
33
|
prerelease: false
|
25
|
-
|
34
|
+
type: :development
|
35
|
+
requirement: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
26
38
|
none: false
|
27
|
-
requirements:
|
28
|
-
- -
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
|
31
|
-
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
32
46
|
name: bundler
|
33
|
-
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
|
-
requirements:
|
36
|
-
- - ! '>='
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: '0'
|
39
|
-
type: :development
|
40
47
|
prerelease: false
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: jeweler
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
48
|
+
type: :development
|
49
|
+
requirement: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
50
52
|
none: false
|
51
|
-
requirements:
|
53
|
+
requirements:
|
52
54
|
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 49
|
57
|
+
segments:
|
58
|
+
- 1
|
59
|
+
- 8
|
60
|
+
- 3
|
54
61
|
version: 1.8.3
|
55
|
-
|
62
|
+
name: jeweler
|
56
63
|
prerelease: false
|
57
|
-
|
64
|
+
type: :development
|
65
|
+
requirement: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
58
68
|
none: false
|
59
|
-
requirements:
|
60
|
-
- -
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
|
63
|
-
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
64
76
|
name: rspec
|
65
|
-
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
|
-
requirements:
|
68
|
-
- - ! '>='
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '0'
|
71
|
-
type: :development
|
72
77
|
prerelease: false
|
73
|
-
|
74
|
-
|
75
|
-
requirements:
|
76
|
-
- - ! '>='
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: '0'
|
78
|
+
type: :development
|
79
|
+
requirement: *id004
|
79
80
|
description: Ruby extension for the vips image processing library.
|
80
81
|
email: jcupitt@gmail.com
|
81
82
|
executables: []
|
82
|
-
|
83
|
+
|
84
|
+
extensions:
|
83
85
|
- ext/extconf.rb
|
84
|
-
extra_rdoc_files:
|
86
|
+
extra_rdoc_files:
|
85
87
|
- LICENSE
|
86
88
|
- README.md
|
87
89
|
- TODO
|
88
|
-
files:
|
90
|
+
files:
|
89
91
|
- CHANGELOG.md
|
90
92
|
- Gemfile.lock
|
91
93
|
- README.md
|
@@ -135,32 +137,37 @@ files:
|
|
135
137
|
- LICENSE
|
136
138
|
- TODO
|
137
139
|
homepage: http://github.com/jcupitt/ruby-vips
|
138
|
-
licenses:
|
140
|
+
licenses:
|
139
141
|
- MIT
|
140
142
|
post_install_message:
|
141
143
|
rdoc_options: []
|
142
|
-
|
144
|
+
|
145
|
+
require_paths:
|
143
146
|
- lib
|
144
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
148
|
none: false
|
146
|
-
requirements:
|
147
|
-
- -
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
|
150
|
-
segments:
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
hash: 3
|
153
|
+
segments:
|
151
154
|
- 0
|
152
|
-
|
153
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
version: "0"
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
157
|
none: false
|
155
|
-
requirements:
|
156
|
-
- -
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
hash: 3
|
162
|
+
segments:
|
163
|
+
- 0
|
164
|
+
version: "0"
|
159
165
|
requirements: []
|
166
|
+
|
160
167
|
rubyforge_project:
|
161
|
-
rubygems_version: 1.8.
|
168
|
+
rubygems_version: 1.8.15
|
162
169
|
signing_key:
|
163
170
|
specification_version: 3
|
164
|
-
summary: ruby-vips is a ruby extension for vips. It is extremely fast and it can process
|
165
|
-
huge images without requiring the entire image to be loaded into memory.
|
171
|
+
summary: ruby-vips is a ruby extension for vips. It is extremely fast and it can process huge images without requiring the entire image to be loaded into memory.
|
166
172
|
test_files: []
|
173
|
+
|