ruby-vips 2.0.13 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +42 -0
- data/.github/workflows/test.yml +80 -0
- data/.standard.yml +17 -0
- data/.yardopts +0 -1
- data/CHANGELOG.md +44 -0
- data/Gemfile +3 -1
- data/README.md +45 -47
- data/Rakefile +13 -15
- data/TODO +19 -10
- data/VERSION +1 -1
- data/example/annotate.rb +7 -7
- data/example/connection.rb +26 -0
- data/example/daltonize8.rb +27 -29
- data/example/draw_lines.rb +30 -0
- data/example/example1.rb +5 -6
- data/example/example2.rb +11 -11
- data/example/example3.rb +9 -9
- data/example/example4.rb +8 -8
- data/example/example5.rb +8 -9
- data/example/inheritance_with_refcount.rb +203 -221
- data/example/progress.rb +30 -0
- data/example/thumb.rb +12 -14
- data/example/trim8.rb +7 -7
- data/example/watermark.rb +15 -36
- data/example/wobble.rb +25 -25
- data/lib/ruby-vips.rb +1 -1
- data/lib/vips.rb +473 -338
- data/lib/vips/access.rb +9 -9
- data/lib/vips/align.rb +7 -8
- data/lib/vips/angle.rb +8 -9
- data/lib/vips/angle45.rb +12 -13
- data/lib/vips/bandformat.rb +16 -18
- data/lib/vips/blend_mode.rb +36 -0
- data/lib/vips/coding.rb +11 -12
- data/lib/vips/compass_direction.rb +13 -14
- data/lib/vips/connection.rb +46 -0
- data/lib/vips/direction.rb +7 -8
- data/lib/vips/extend.rb +13 -14
- data/lib/vips/gobject.rb +111 -100
- data/lib/vips/gvalue.rb +243 -237
- data/lib/vips/image.rb +1501 -1338
- data/lib/vips/interesting.rb +10 -11
- data/lib/vips/interpolate.rb +50 -54
- data/lib/vips/interpretation.rb +25 -26
- data/lib/vips/kernel.rb +18 -19
- data/lib/vips/methods.rb +929 -309
- data/lib/vips/mutableimage.rb +154 -0
- data/lib/vips/object.rb +318 -208
- data/lib/vips/operation.rb +467 -320
- data/lib/vips/operationboolean.rb +10 -11
- data/lib/vips/operationcomplex.rb +8 -9
- data/lib/vips/operationcomplex2.rb +6 -7
- data/lib/vips/operationcomplexget.rb +7 -8
- data/lib/vips/operationmath.rb +14 -15
- data/lib/vips/operationmath2.rb +6 -7
- data/lib/vips/operationrelational.rb +11 -12
- data/lib/vips/operationround.rb +7 -8
- data/lib/vips/region.rb +73 -0
- data/lib/vips/size.rb +9 -10
- data/lib/vips/source.rb +88 -0
- data/lib/vips/sourcecustom.rb +89 -0
- data/lib/vips/target.rb +86 -0
- data/lib/vips/targetcustom.rb +77 -0
- data/lib/vips/version.rb +1 -2
- data/ruby-vips.gemspec +29 -20
- metadata +51 -40
- data/.travis.yml +0 -55
- data/install-vips.sh +0 -26
data/lib/vips/target.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# This module provides an interface to the top level bits of libvips
|
2
|
+
# via ruby-ffi.
|
3
|
+
#
|
4
|
+
# Author:: John Cupitt (mailto:jcupitt@gmail.com)
|
5
|
+
# License:: MIT
|
6
|
+
|
7
|
+
require "ffi"
|
8
|
+
|
9
|
+
module Vips
|
10
|
+
if Vips.at_least_libvips?(8, 9)
|
11
|
+
attach_function :vips_target_new_to_descriptor, [:int], :pointer
|
12
|
+
attach_function :vips_target_new_to_file, [:string], :pointer
|
13
|
+
attach_function :vips_target_new_to_memory, [], :pointer
|
14
|
+
end
|
15
|
+
|
16
|
+
# A target. For example:
|
17
|
+
#
|
18
|
+
# ```ruby
|
19
|
+
# target = Vips::Target.new_to_file('k2.jpg')
|
20
|
+
# image.write_to_target(target, '.jpg')
|
21
|
+
# ```
|
22
|
+
class Target < Vips::Connection
|
23
|
+
# The layout of the VipsRegion struct.
|
24
|
+
module TargetLayout
|
25
|
+
def self.included(base)
|
26
|
+
base.class_eval do
|
27
|
+
layout :parent, Vips::Connection::Struct
|
28
|
+
# rest opaque
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Struct < Vips::Connection::Struct
|
34
|
+
include TargetLayout
|
35
|
+
end
|
36
|
+
|
37
|
+
class ManagedStruct < Vips::Connection::ManagedStruct
|
38
|
+
include TargetLayout
|
39
|
+
end
|
40
|
+
|
41
|
+
# Create a new target to a file descriptor. File descriptors are
|
42
|
+
# small integers, for example 1 is stdout.
|
43
|
+
#
|
44
|
+
# Pass targets to {Image#write_to_target} to write images to
|
45
|
+
# them.
|
46
|
+
#
|
47
|
+
# @param descriptor [Integer] the file descriptor
|
48
|
+
# @return [Target] the new Vips::Target
|
49
|
+
def self.new_to_descriptor(descriptor)
|
50
|
+
ptr = Vips.vips_target_new_to_descriptor descriptor
|
51
|
+
raise Vips::Error if ptr.null?
|
52
|
+
|
53
|
+
Vips::Target.new ptr
|
54
|
+
end
|
55
|
+
|
56
|
+
# Create a new target to a file name.
|
57
|
+
#
|
58
|
+
# Pass targets to {Image#write_to_target} to write images to
|
59
|
+
# them.
|
60
|
+
#
|
61
|
+
# @param filename [String] the name of the file
|
62
|
+
# @return [Target] the new Vips::Target
|
63
|
+
def self.new_to_file(filename)
|
64
|
+
raise Vips::Error, "filename is nil" if filename.nil?
|
65
|
+
ptr = Vips.vips_target_new_to_file filename
|
66
|
+
raise Vips::Error if ptr.null?
|
67
|
+
|
68
|
+
Vips::Target.new ptr
|
69
|
+
end
|
70
|
+
|
71
|
+
# Create a new target to an area of memory.
|
72
|
+
#
|
73
|
+
# Pass targets to {Image#write_to_target} to write images to
|
74
|
+
# them.
|
75
|
+
#
|
76
|
+
# Once the image has been written, use {Object#get}`("blob")` to read out
|
77
|
+
# the data.
|
78
|
+
#
|
79
|
+
# @return [Target] the new Vips::Target
|
80
|
+
def self.new_to_memory
|
81
|
+
ptr = Vips.vips_target_new_to_memory
|
82
|
+
|
83
|
+
Vips::Target.new ptr
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# This module provides an interface to the top level bits of libvips
|
2
|
+
# via ruby-ffi.
|
3
|
+
#
|
4
|
+
# Author:: John Cupitt (mailto:jcupitt@gmail.com)
|
5
|
+
# License:: MIT
|
6
|
+
|
7
|
+
require "ffi"
|
8
|
+
|
9
|
+
module Vips
|
10
|
+
if Vips.at_least_libvips?(8, 9)
|
11
|
+
attach_function :vips_target_custom_new, [], :pointer
|
12
|
+
end
|
13
|
+
|
14
|
+
# A target you can attach action signal handlers to to implememt
|
15
|
+
# custom output types.
|
16
|
+
#
|
17
|
+
# For example:
|
18
|
+
#
|
19
|
+
# ```ruby
|
20
|
+
# file = File.open "some/file/name", "wb"
|
21
|
+
# target = Vips::TargetCustom.new
|
22
|
+
# target.on_write { |bytes| file.write bytes }
|
23
|
+
# image.write_to_target target, ".png"
|
24
|
+
# ```
|
25
|
+
#
|
26
|
+
# (just an example -- of course in practice you'd use {Target#new_to_file}
|
27
|
+
# to write to a named file)
|
28
|
+
class TargetCustom < Vips::Target
|
29
|
+
module TargetCustomLayout
|
30
|
+
def self.included(base)
|
31
|
+
base.class_eval do
|
32
|
+
layout :parent, Vips::Target::Struct
|
33
|
+
# rest opaque
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Struct < Vips::Target::Struct
|
39
|
+
include TargetCustomLayout
|
40
|
+
end
|
41
|
+
|
42
|
+
class ManagedStruct < Vips::Target::ManagedStruct
|
43
|
+
include TargetCustomLayout
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize
|
47
|
+
pointer = Vips.vips_target_custom_new
|
48
|
+
raise Vips::Error if pointer.null?
|
49
|
+
|
50
|
+
super pointer
|
51
|
+
end
|
52
|
+
|
53
|
+
# The block is executed to write data to the source. The interface is
|
54
|
+
# exactly as IO::write, ie. it should write the string and return the
|
55
|
+
# number of bytes written.
|
56
|
+
#
|
57
|
+
# @yieldparam bytes [String] Write these bytes to the file
|
58
|
+
# @yieldreturn [Integer] The number of bytes written, or -1 on error
|
59
|
+
def on_write &block
|
60
|
+
signal_connect "write" do |p, len|
|
61
|
+
chunk = p.get_bytes(0, len)
|
62
|
+
bytes_written = block.call chunk
|
63
|
+
chunk.clear
|
64
|
+
|
65
|
+
bytes_written
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# The block is executed at the end of write. It should do any necessary
|
70
|
+
# finishing action, such as closing a file.
|
71
|
+
def on_finish &block
|
72
|
+
signal_connect "finish" do
|
73
|
+
block.call
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/vips/version.rb
CHANGED
data/ruby-vips.gemspec
CHANGED
@@ -1,39 +1,48 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require 'vips/version'
|
3
|
+
require_relative "lib/vips/version"
|
6
4
|
|
7
5
|
Gem::Specification.new do |spec|
|
8
6
|
spec.name = "ruby-vips"
|
9
7
|
spec.version = Vips::VERSION
|
8
|
+
spec.summary = "A fast image processing library with low memory needs"
|
9
|
+
spec.description = <<-DESC.strip
|
10
|
+
ruby-vips is a binding for the libvips image processing library. It is fast
|
11
|
+
and it can process large images without loading the whole image in memory.
|
12
|
+
DESC
|
13
|
+
spec.homepage = "http://github.com/libvips/ruby-vips"
|
14
|
+
spec.licenses = ["MIT"]
|
10
15
|
spec.authors = ["John Cupitt"]
|
11
|
-
spec.email = "jcupitt@gmail.com"
|
16
|
+
spec.email = ["jcupitt@gmail.com"]
|
12
17
|
|
13
|
-
spec.
|
14
|
-
|
15
|
-
|
16
|
-
|
18
|
+
spec.metadata = {
|
19
|
+
"bug_tracker_uri" => "https://github.com/libvips/ruby-vips/issues",
|
20
|
+
"changelog_uri" =>
|
21
|
+
"https://github.com/libvips/ruby-vips/blob/master/CHANGELOG.md",
|
22
|
+
"documentation_uri" => "https://www.rubydoc.info/gems/ruby-vips",
|
23
|
+
"homepage_uri" => spec.homepage,
|
24
|
+
"source_code_uri" => "https://github.com/libvips/ruby-vips",
|
25
|
+
|
26
|
+
"msys2_mingw_dependencies" => "libvips"
|
27
|
+
}
|
17
28
|
|
18
29
|
spec.require_paths = ["lib"]
|
19
|
-
spec.extra_rdoc_files = [
|
20
|
-
"LICENSE.txt",
|
21
|
-
"README.md",
|
22
|
-
"TODO"
|
23
|
-
]
|
30
|
+
spec.extra_rdoc_files = %w[LICENSE.txt README.md TODO]
|
24
31
|
|
25
32
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
33
|
f.match(%r{^(test|spec|features)/})
|
27
34
|
end
|
28
35
|
|
29
|
-
spec.
|
36
|
+
spec.required_ruby_version = ">= 2.0.0"
|
30
37
|
|
31
|
-
spec.
|
38
|
+
spec.add_runtime_dependency "ffi", ["~> 1.12"]
|
39
|
+
|
40
|
+
spec.add_development_dependency "rake", ["~> 12.0"]
|
32
41
|
spec.add_development_dependency "rspec", ["~> 3.3"]
|
33
42
|
spec.add_development_dependency "yard", ["~> 0.9.11"]
|
34
|
-
spec.add_development_dependency "
|
35
|
-
spec.add_development_dependency "github-markup", ["~> 1.4"]
|
36
|
-
spec.add_development_dependency "bundler", ["~> 1.0"]
|
43
|
+
spec.add_development_dependency "bundler", [">= 1.0", "< 3"]
|
37
44
|
|
45
|
+
if Gem.ruby_version >= Gem::Version.new("2.2")
|
46
|
+
spec.add_development_dependency "standard"
|
47
|
+
end
|
38
48
|
end
|
39
|
-
|
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.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Cupitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.12'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.12'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '12.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,50 +67,44 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.9.11
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '3.3'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
73
|
+
- - ">="
|
81
74
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
83
|
-
-
|
84
|
-
name: github-markup
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
75
|
+
version: '1.0'
|
76
|
+
- - "<"
|
88
77
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
78
|
+
version: '3'
|
90
79
|
type: :development
|
91
80
|
prerelease: false
|
92
81
|
version_requirements: !ruby/object:Gem::Requirement
|
93
82
|
requirements:
|
94
|
-
- - "
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1.0'
|
86
|
+
- - "<"
|
95
87
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
88
|
+
version: '3'
|
97
89
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
90
|
+
name: standard
|
99
91
|
requirement: !ruby/object:Gem::Requirement
|
100
92
|
requirements:
|
101
|
-
- - "
|
93
|
+
- - ">="
|
102
94
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
95
|
+
version: '0'
|
104
96
|
type: :development
|
105
97
|
prerelease: false
|
106
98
|
version_requirements: !ruby/object:Gem::Requirement
|
107
99
|
requirements:
|
108
|
-
- - "
|
100
|
+
- - ">="
|
109
101
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
111
|
-
description: ruby-vips is a binding for the
|
112
|
-
fast and it can process
|
113
|
-
|
102
|
+
version: '0'
|
103
|
+
description: "ruby-vips is a binding for the libvips image processing library. It
|
104
|
+
is fast \n and it can process large images without loading the whole image in
|
105
|
+
memory."
|
106
|
+
email:
|
107
|
+
- jcupitt@gmail.com
|
114
108
|
executables: []
|
115
109
|
extensions: []
|
116
110
|
extra_rdoc_files:
|
@@ -118,8 +112,10 @@ extra_rdoc_files:
|
|
118
112
|
- README.md
|
119
113
|
- TODO
|
120
114
|
files:
|
115
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
116
|
+
- ".github/workflows/test.yml"
|
121
117
|
- ".gitignore"
|
122
|
-
- ".
|
118
|
+
- ".standard.yml"
|
123
119
|
- ".yardopts"
|
124
120
|
- CHANGELOG.md
|
125
121
|
- Gemfile
|
@@ -129,18 +125,20 @@ files:
|
|
129
125
|
- TODO
|
130
126
|
- VERSION
|
131
127
|
- example/annotate.rb
|
128
|
+
- example/connection.rb
|
132
129
|
- example/daltonize8.rb
|
130
|
+
- example/draw_lines.rb
|
133
131
|
- example/example1.rb
|
134
132
|
- example/example2.rb
|
135
133
|
- example/example3.rb
|
136
134
|
- example/example4.rb
|
137
135
|
- example/example5.rb
|
138
136
|
- example/inheritance_with_refcount.rb
|
137
|
+
- example/progress.rb
|
139
138
|
- example/thumb.rb
|
140
139
|
- example/trim8.rb
|
141
140
|
- example/watermark.rb
|
142
141
|
- example/wobble.rb
|
143
|
-
- install-vips.sh
|
144
142
|
- lib/ruby-vips.rb
|
145
143
|
- lib/vips.rb
|
146
144
|
- lib/vips/access.rb
|
@@ -148,8 +146,10 @@ files:
|
|
148
146
|
- lib/vips/angle.rb
|
149
147
|
- lib/vips/angle45.rb
|
150
148
|
- lib/vips/bandformat.rb
|
149
|
+
- lib/vips/blend_mode.rb
|
151
150
|
- lib/vips/coding.rb
|
152
151
|
- lib/vips/compass_direction.rb
|
152
|
+
- lib/vips/connection.rb
|
153
153
|
- lib/vips/direction.rb
|
154
154
|
- lib/vips/extend.rb
|
155
155
|
- lib/vips/gobject.rb
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- lib/vips/interpretation.rb
|
161
161
|
- lib/vips/kernel.rb
|
162
162
|
- lib/vips/methods.rb
|
163
|
+
- lib/vips/mutableimage.rb
|
163
164
|
- lib/vips/object.rb
|
164
165
|
- lib/vips/operation.rb
|
165
166
|
- lib/vips/operationboolean.rb
|
@@ -170,13 +171,24 @@ files:
|
|
170
171
|
- lib/vips/operationmath2.rb
|
171
172
|
- lib/vips/operationrelational.rb
|
172
173
|
- lib/vips/operationround.rb
|
174
|
+
- lib/vips/region.rb
|
173
175
|
- lib/vips/size.rb
|
176
|
+
- lib/vips/source.rb
|
177
|
+
- lib/vips/sourcecustom.rb
|
178
|
+
- lib/vips/target.rb
|
179
|
+
- lib/vips/targetcustom.rb
|
174
180
|
- lib/vips/version.rb
|
175
181
|
- ruby-vips.gemspec
|
176
|
-
homepage: http://github.com/
|
182
|
+
homepage: http://github.com/libvips/ruby-vips
|
177
183
|
licenses:
|
178
184
|
- MIT
|
179
|
-
metadata:
|
185
|
+
metadata:
|
186
|
+
bug_tracker_uri: https://github.com/libvips/ruby-vips/issues
|
187
|
+
changelog_uri: https://github.com/libvips/ruby-vips/blob/master/CHANGELOG.md
|
188
|
+
documentation_uri: https://www.rubydoc.info/gems/ruby-vips
|
189
|
+
homepage_uri: http://github.com/libvips/ruby-vips
|
190
|
+
source_code_uri: https://github.com/libvips/ruby-vips
|
191
|
+
msys2_mingw_dependencies: libvips
|
180
192
|
post_install_message:
|
181
193
|
rdoc_options: []
|
182
194
|
require_paths:
|
@@ -185,16 +197,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
197
|
requirements:
|
186
198
|
- - ">="
|
187
199
|
- !ruby/object:Gem::Version
|
188
|
-
version:
|
200
|
+
version: 2.0.0
|
189
201
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
202
|
requirements:
|
191
203
|
- - ">="
|
192
204
|
- !ruby/object:Gem::Version
|
193
205
|
version: '0'
|
194
206
|
requirements: []
|
195
|
-
|
196
|
-
rubygems_version: 2.7.6
|
207
|
+
rubygems_version: 3.1.2
|
197
208
|
signing_key:
|
198
209
|
specification_version: 4
|
199
|
-
summary:
|
210
|
+
summary: A fast image processing library with low memory needs
|
200
211
|
test_files: []
|