vips 8.8.4 → 8.12.1
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/development.yml +54 -0
- data/.standard.yml +17 -0
- data/.travis.yml +1 -0
- data/.yardopts +0 -1
- data/CHANGELOG.md +50 -0
- data/Gemfile +8 -1
- data/README.md +31 -15
- data/Rakefile +23 -18
- data/TODO +43 -0
- data/example/annotate.rb +6 -6
- data/example/connection.rb +26 -0
- data/example/daltonize8.rb +6 -6
- data/example/draw_lines.rb +30 -0
- data/example/example1.rb +4 -4
- data/example/example2.rb +6 -6
- data/example/example3.rb +5 -5
- data/example/example4.rb +2 -2
- data/example/example5.rb +4 -4
- data/example/inheritance_with_refcount.rb +46 -39
- data/example/progress.rb +30 -0
- data/example/thumb.rb +6 -6
- data/example/trim8.rb +1 -1
- data/example/watermark.rb +2 -2
- data/example/wobble.rb +1 -1
- data/lib/vips/blend_mode.rb +29 -25
- data/lib/vips/connection.rb +46 -0
- data/lib/vips/gobject.rb +27 -12
- data/lib/vips/gvalue.rb +62 -50
- data/lib/vips/image.rb +548 -287
- data/lib/vips/interpolate.rb +3 -2
- data/lib/vips/methods.rb +2877 -2319
- data/lib/vips/mutableimage.rb +173 -0
- data/lib/vips/object.rb +159 -54
- data/lib/vips/operation.rb +286 -117
- data/lib/vips/region.rb +73 -0
- 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 -1
- data/lib/vips.rb +199 -80
- data/vips.gemspec +3 -3
- metadata +36 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 872a3771eee6d56c17254a27013a7ff1d002506965bf488fad3d055817457f1a
|
4
|
+
data.tar.gz: 76930aa9a3b5456460be220e3373c3a7ff573a86f18c3e07a3cd4ebbf37614af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51239e27dfe2b430985f875150abc758f2f4756fca00647e4c976ff36e4569da42a67bf236988bb244c3e4c8d2043d1d2308baceb58833accb0434460fc2ca87
|
7
|
+
data.tar.gz: 11e11cfdece5955686490f861ef20abcfd283d1d2875f5c7212cfabd0bf03aff8589e085e9277b61cd8d0bb71fef6db309617d93134590e574b6817722637d81
|
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to help us improve
|
4
|
+
title: ''
|
5
|
+
labels: bug
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Questions or suggestions**
|
11
|
+
|
12
|
+
We are using [Discussions](https://github.com/libvips/ruby-vips/discussions) for questions and suggestions for new features. Issues are only for bug reports.
|
13
|
+
|
14
|
+
**Describe the bug**
|
15
|
+
A clear and concise description of what the bug is.
|
16
|
+
|
17
|
+
**To Reproduce**
|
18
|
+
Steps to reproduce the behavior:
|
19
|
+
1. Go to '...'
|
20
|
+
2. Click on '....'
|
21
|
+
3. Scroll down to '....'
|
22
|
+
4. See error
|
23
|
+
|
24
|
+
**Expected behavior**
|
25
|
+
A clear and concise description of what you expected to happen.
|
26
|
+
|
27
|
+
**Screenshots**
|
28
|
+
If applicable, add screenshots to help explain your problem.
|
29
|
+
|
30
|
+
**Desktop (please complete the following information):**
|
31
|
+
- OS: [e.g. iOS]
|
32
|
+
- Browser [e.g. chrome, safari]
|
33
|
+
- Version [e.g. 22]
|
34
|
+
|
35
|
+
**Smartphone (please complete the following information):**
|
36
|
+
- Device: [e.g. iPhone6]
|
37
|
+
- OS: [e.g. iOS8.1]
|
38
|
+
- Browser [e.g. stock browser, safari]
|
39
|
+
- Version [e.g. 22]
|
40
|
+
|
41
|
+
**Additional context**
|
42
|
+
Add any other context about the problem here.
|
@@ -0,0 +1,54 @@
|
|
1
|
+
name: Development
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
name: ${{matrix.ruby}} on ${{matrix.os}}
|
8
|
+
runs-on: ${{matrix.os}}-latest
|
9
|
+
continue-on-error: ${{matrix.experimental}}
|
10
|
+
|
11
|
+
strategy:
|
12
|
+
matrix:
|
13
|
+
os:
|
14
|
+
- ubuntu
|
15
|
+
# - macos
|
16
|
+
|
17
|
+
ruby:
|
18
|
+
- "2.6"
|
19
|
+
- "2.7"
|
20
|
+
- "3.0"
|
21
|
+
- "3.1"
|
22
|
+
|
23
|
+
experimental: [false]
|
24
|
+
env: [""]
|
25
|
+
|
26
|
+
include:
|
27
|
+
- os: ubuntu
|
28
|
+
ruby: truffleruby
|
29
|
+
experimental: true
|
30
|
+
- os: ubuntu
|
31
|
+
ruby: jruby
|
32
|
+
experimental: true
|
33
|
+
- os: ubuntu
|
34
|
+
ruby: head
|
35
|
+
experimental: true
|
36
|
+
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v2
|
39
|
+
- uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: ${{matrix.ruby}}
|
42
|
+
bundler-cache: true
|
43
|
+
|
44
|
+
- name: Install libvips
|
45
|
+
env:
|
46
|
+
DEBIAN_FRONTEND: noninteractive
|
47
|
+
run: |
|
48
|
+
sudo apt-get update -qq -o Acquire::Retries=3
|
49
|
+
sudo apt-get install --fix-missing -qq -o Acquire::Retries=3 libvips
|
50
|
+
bundle exec rake ext
|
51
|
+
|
52
|
+
- name: Run tests
|
53
|
+
timeout-minutes: 5
|
54
|
+
run: ${{matrix.env}} bundle exec rake spec
|
data/.standard.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
fix: false # default: false
|
2
|
+
parallel: true # default: false
|
3
|
+
format: progress # default: Standard::Formatter
|
4
|
+
ruby_version: 2.0 # default: RUBY_VERSION
|
5
|
+
default_ignores: false # default: true
|
6
|
+
|
7
|
+
ignore: # default: []
|
8
|
+
- '**/*':
|
9
|
+
- Standard/SemanticBlocks
|
10
|
+
- 'lib/vips/methods.rb'
|
11
|
+
- '{lib,example}/**/*':
|
12
|
+
- Lint/IneffectiveAccessModifier
|
13
|
+
- Lint/RescueException
|
14
|
+
- Style/GlobalVars
|
15
|
+
- 'spec/**/*':
|
16
|
+
- Lint/BinaryOperatorWithIdenticalOperands
|
17
|
+
- 'vendor/**/*'
|
data/.travis.yml
CHANGED
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,56 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## Version 2.1.4 (2021-10-28)
|
6
|
+
|
7
|
+
* `write_to_buffer` tries to use the new target API, then falls back to the old
|
8
|
+
buffer system [jcupitt]
|
9
|
+
* don't generate yard docs for deprecated args [jcupitt]
|
10
|
+
* add hyperbolic trig functions [jcupitt]
|
11
|
+
|
12
|
+
## Version 2.1.3 (2021-8-23)
|
13
|
+
|
14
|
+
* fix a gtype size error on win64 [danini-the-panini]
|
15
|
+
|
16
|
+
## Version 2.1.2 (2021-5-3)
|
17
|
+
|
18
|
+
* allow `FFI::Pointer` as an argument to `new_from_memory` etc. [sled]
|
19
|
+
|
20
|
+
## Version 2.1.1 (2021-5-3)
|
21
|
+
|
22
|
+
* fix "mutate" with libvips 8.9 [jcupitt]
|
23
|
+
* update autodocs for libvips 8.11 [jcupitt]
|
24
|
+
|
25
|
+
## Version 2.1.0 (2021-3-8)
|
26
|
+
|
27
|
+
* add "mutate" system [jcupitt]
|
28
|
+
* better behaviour with some nil parameters [jcupitt]
|
29
|
+
* revise gemspec [jcupitt]
|
30
|
+
* allow symbols for Interpolate.new [noraj]
|
31
|
+
* update docs for 8.10, fix minor doc formatting issues [jcupitt]
|
32
|
+
* `new_from_array` checks array argument more carefully [dkam]
|
33
|
+
* add `new_from_memory` and `new_from_memory_copy` [ankane]
|
34
|
+
* jruby added to CI testing [pftg]
|
35
|
+
* switch to github actions for CI [pftg]
|
36
|
+
* remove rubocop, revise formatting for standardrb [pftg]
|
37
|
+
|
38
|
+
## Version 2.0.17 (2019-10-29)
|
39
|
+
|
40
|
+
* install msys2 libvips on Windows [larskanis]
|
41
|
+
* better `-` to `_` conversion [Nakilon]
|
42
|
+
* fix `GValue#set` for stricter metadata rules in 8.9 [jcupitt]
|
43
|
+
* fix a ref leak on operation build error [jcupitt]
|
44
|
+
* faster operation call [jcupitt]
|
45
|
+
* add support for VipsConnection [jcupitt]
|
46
|
+
* add `signal_connect` [jcupitt]
|
47
|
+
* add `Image#set_kill` for progress termination [jcupitt]
|
48
|
+
|
49
|
+
## Version 2.0.16 (2019-9-21)
|
50
|
+
|
51
|
+
* better library name generation [renchap]
|
52
|
+
* allow `_` as a separator in enum names [D-W-L]
|
53
|
+
* add `Vips::Region` and `Region#fetch` [jcupitt]
|
54
|
+
|
5
55
|
## Version 2.0.15 (2019-6-12)
|
6
56
|
|
7
57
|
* better error messages from `write_to_memory` [linkyndy]
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,27 +1,26 @@
|
|
1
1
|
# Vips
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/ruby-vips.svg)](https://badge.fury.io/rb/ruby-vips)
|
4
|
+
[![Test](https://github.com/libvips/ruby-vips/workflows/Test/badge.svg)](https://github.com/libvips/ruby-vips/actions?query=workflow%3ATest)
|
5
|
+
|
3
6
|
This gem is a backwards compatible fork of `ruby-vips` but also includes (and compiles) the [libvips] source code.
|
4
7
|
|
5
|
-
[
|
8
|
+
libvips is a [demand-driven, horizontally
|
9
|
+
threaded](https://github.com/libvips/libvips/wiki/Why-is-libvips-quick)
|
10
|
+
image processing library. Compared to similar
|
11
|
+
libraries, [libvips runs quickly and uses little
|
12
|
+
memory](https://github.com/libvips/libvips/wiki/Speed-and-memory-use).
|
13
|
+
libvips is licensed under the [LGPL
|
14
|
+
2.1+](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html).
|
6
15
|
|
7
|
-
[libvips]: https://
|
16
|
+
[libvips]: https://libvips.github.io/libvips
|
8
17
|
|
9
18
|
## Installation
|
10
19
|
|
11
|
-
|
12
|
-
|
13
|
-
```ruby
|
14
|
-
gem 'vips'
|
20
|
+
``` shell
|
21
|
+
$ bundle add vips
|
15
22
|
```
|
16
23
|
|
17
|
-
And then execute:
|
18
|
-
|
19
|
-
$ bundle
|
20
|
-
|
21
|
-
Or install it yourself as:
|
22
|
-
|
23
|
-
$ gem install vips
|
24
|
-
|
25
24
|
You'll still need to install `glib` and `gobject-introspection`.
|
26
25
|
|
27
26
|
## Usage
|
@@ -38,7 +37,24 @@ Exactly the same way as [ruby-vips].
|
|
38
37
|
4. Push to the branch (`git push origin my-new-feature`)
|
39
38
|
5. Create new Pull Request
|
40
39
|
|
41
|
-
##
|
40
|
+
## Documentation
|
41
|
+
|
42
|
+
There are [full API docs for ruby-vips on
|
43
|
+
rubydoc](https://www.rubydoc.info/gems/ruby-vips). This sometimes has issues
|
44
|
+
updating, so we have a [copy on the gh-pages for this site as
|
45
|
+
well](http://libvips.github.io/ruby-vips), which
|
46
|
+
should always work.
|
47
|
+
|
48
|
+
See the `Vips` section in the docs for a [tutorial introduction with
|
49
|
+
examples](https://www.rubydoc.info/gems/ruby-vips/Vips).
|
50
|
+
|
51
|
+
The [libvips reference manual](https://libvips.github.io/libvips/API/current/)
|
52
|
+
has a complete explanation of every method.
|
53
|
+
|
54
|
+
The [`example/`](https://github.com/libvips/ruby-vips/tree/master/example)
|
55
|
+
directory has some simple example programs.
|
56
|
+
|
57
|
+
## Benchmarks
|
42
58
|
|
43
59
|
Released under the MIT license.
|
44
60
|
|
data/Rakefile
CHANGED
@@ -1,28 +1,33 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
2
|
|
4
|
-
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
warn e.message
|
7
|
+
warn "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
5
10
|
|
6
|
-
|
11
|
+
require "rake"
|
7
12
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
13
|
+
require "rspec/core"
|
14
|
+
require "rspec/core/rake_task"
|
15
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
16
|
+
spec.pattern = FileList["spec/**/*_spec.rb"]
|
12
17
|
end
|
13
18
|
|
14
|
-
task :
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
task default: :spec
|
20
|
+
|
21
|
+
task :ext do
|
22
|
+
Dir.chdir "ext" do
|
23
|
+
sh "rake"
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
|
-
|
27
|
+
unless RUBY_PLATFORM.include?("java")
|
28
|
+
require "github/markup"
|
29
|
+
require "yard"
|
30
|
+
require "yard/rake/yardoc_task"
|
23
31
|
|
24
|
-
YARD::Rake::YardocTask.new
|
25
|
-
require "yard"
|
26
|
-
require "github/markup"
|
27
|
-
require "redcarpet"
|
32
|
+
YARD::Rake::YardocTask.new
|
28
33
|
end
|
data/TODO
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Notes
|
2
|
+
|
3
|
+
- We should support complex constants, eg:
|
4
|
+
|
5
|
+
Complex(1, 2)
|
6
|
+
=> (1+2i)
|
7
|
+
|
8
|
+
# Common operations
|
9
|
+
|
10
|
+
- Lint.
|
11
|
+
|
12
|
+
bundle exec standardrb
|
13
|
+
|
14
|
+
- Reinstall local copy of gem after a change.
|
15
|
+
|
16
|
+
bundle exec rake install
|
17
|
+
|
18
|
+
- Run test suite.
|
19
|
+
|
20
|
+
bundle exec rake
|
21
|
+
|
22
|
+
- Version bump.
|
23
|
+
|
24
|
+
edit lib/vips/version.rb
|
25
|
+
edit VERSION
|
26
|
+
|
27
|
+
- Regenerate autodocs.
|
28
|
+
|
29
|
+
cd lib/vips
|
30
|
+
ruby > methods.rb
|
31
|
+
require "vips"; Vips::Yard.generate
|
32
|
+
^D
|
33
|
+
|
34
|
+
- Regenerate docs.
|
35
|
+
|
36
|
+
bundle exec rake yard
|
37
|
+
|
38
|
+
- Push new gem to rubygems, tag repository with version.
|
39
|
+
|
40
|
+
bundle exec rake release
|
41
|
+
|
42
|
+
You'll be asked for a otp from authy / google authenticator / etc.
|
43
|
+
|
data/example/annotate.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require "vips"
|
4
4
|
|
5
|
-
im = Vips::Image.new_from_file ARGV[0], :
|
5
|
+
im = Vips::Image.new_from_file ARGV[0], access: :sequential
|
6
6
|
|
7
|
-
left_text = Vips::Image.text "left corner", :
|
7
|
+
left_text = Vips::Image.text "left corner", dpi: 300
|
8
8
|
left = left_text.embed 50, 50, im.width, 150
|
9
9
|
|
10
|
-
right_text = Vips::Image.text "right corner", :
|
10
|
+
right_text = Vips::Image.text "right corner", dpi: 300
|
11
11
|
right = right_text.embed im.width - right_text.width - 50, 50, im.width, 150
|
12
12
|
|
13
|
-
footer = (left | right).ifthenelse(0, [255, 0, 0], :
|
13
|
+
footer = (left | right).ifthenelse(0, [255, 0, 0], blend: true)
|
14
14
|
|
15
|
-
im = im.insert footer, 0, im.height, :
|
15
|
+
im = im.insert footer, 0, im.height, expand: true
|
16
16
|
|
17
17
|
im.write_to_file ARGV[1]
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require "vips"
|
4
|
+
require "down/http"
|
5
|
+
|
6
|
+
# byte_source = File.open ARGV[0], "rb"
|
7
|
+
# eg. https://images.unsplash.com/photo-1491933382434-500287f9b54b
|
8
|
+
byte_source = Down::Http.open(ARGV[0])
|
9
|
+
|
10
|
+
source = Vips::SourceCustom.new
|
11
|
+
source.on_read do |length|
|
12
|
+
puts "reading #{length} bytes ..."
|
13
|
+
byte_source.read length
|
14
|
+
end
|
15
|
+
source.on_seek do |offset, whence|
|
16
|
+
puts "seeking to #{offset}, #{whence}"
|
17
|
+
byte_source.seek(offset, whence)
|
18
|
+
end
|
19
|
+
|
20
|
+
byte_target = File.open ARGV[1], "wb"
|
21
|
+
target = Vips::TargetCustom.new
|
22
|
+
target.on_write { |chunk| byte_target.write(chunk) }
|
23
|
+
target.on_finish { byte_target.close }
|
24
|
+
|
25
|
+
image = Vips::Image.new_from_source source, "", access: :sequential
|
26
|
+
image.write_to_target target, ".jpg"
|
data/example/daltonize8.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# http://libvips.blogspot.co.uk/2013/05/daltonize-in-ruby-vips-carrierwave-and.html
|
8
8
|
# for a discussion of this code
|
9
9
|
|
10
|
-
require
|
10
|
+
require "vips"
|
11
11
|
|
12
12
|
# Vips.set_debug true
|
13
13
|
|
@@ -29,13 +29,13 @@ im = Vips::Image.new_from_file ARGV[0]
|
|
29
29
|
alpha = nil
|
30
30
|
if im.bands == 4
|
31
31
|
alpha = im[3]
|
32
|
-
im = im.extract_band 0, :
|
32
|
+
im = im.extract_band 0, n: 3
|
33
33
|
end
|
34
34
|
|
35
35
|
begin
|
36
36
|
# import to XYZ with lcms
|
37
37
|
# if there's no profile there, we'll fall back to the thing below
|
38
|
-
xyz = im.icc_import :
|
38
|
+
xyz = im.icc_import embedded: true, pcs: :xyz
|
39
39
|
rescue Vips::Error
|
40
40
|
# nope .. use the built-in converter instead
|
41
41
|
xyz = im.colourspace :xyz
|
@@ -61,9 +61,9 @@ rgb = xyz.colourspace :srgb
|
|
61
61
|
err = im - rgb
|
62
62
|
|
63
63
|
# add the error back to other channels to make a compensated image
|
64
|
-
im
|
65
|
-
|
66
|
-
|
64
|
+
im += err.recomb([[0, 0, 0],
|
65
|
+
[0.7, 1, 0],
|
66
|
+
[0.7, 0, 1]])
|
67
67
|
|
68
68
|
# reattach any alpha we saved above
|
69
69
|
if alpha
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require "vips"
|
4
|
+
|
5
|
+
# load and stream into memory
|
6
|
+
image = Vips::Image.new_from_file(ARGV[0], access: :sequential).copy_memory
|
7
|
+
|
8
|
+
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
9
|
+
|
10
|
+
lines = image
|
11
|
+
(0..1).step 0.01 do |i|
|
12
|
+
lines = lines.draw_line 255, lines.width * i, 0, 0, lines.height * (1 - i)
|
13
|
+
end
|
14
|
+
|
15
|
+
ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
16
|
+
puts "non-destructive took #{ending - starting}s"
|
17
|
+
|
18
|
+
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
19
|
+
|
20
|
+
lines = image
|
21
|
+
lines = lines.mutate do |x|
|
22
|
+
(0..1).step 0.01 do |i|
|
23
|
+
x.draw_line! 255, x.width * i, 0, 0, x.height * (1 - i)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
28
|
+
puts "mutate took #{ending - starting}s"
|
29
|
+
|
30
|
+
lines.write_to_file ARGV[1]
|
data/example/example1.rb
CHANGED
data/example/example2.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "logger"
|
4
|
+
require "vips"
|
5
5
|
|
6
6
|
puts ""
|
7
7
|
puts "starting up:"
|
8
8
|
|
9
9
|
# this makes vips keep a list of all active objects which we can print out
|
10
|
-
Vips
|
10
|
+
Vips.leak_set true
|
11
11
|
|
12
12
|
# disable the operation cache
|
13
|
-
Vips
|
13
|
+
Vips.cache_set_max 0
|
14
14
|
|
15
15
|
# GLib::logger.level = Logger::DEBUG
|
16
16
|
|
@@ -20,7 +20,7 @@ n.times do |i|
|
|
20
20
|
puts ""
|
21
21
|
puts "call #{i} ..."
|
22
22
|
out = Vips::Operation.call "black", [200, 300]
|
23
|
-
if out.width != 200
|
23
|
+
if out.width != 200 || out.height != 300
|
24
24
|
puts "bad image result from black"
|
25
25
|
end
|
26
26
|
end
|
@@ -28,7 +28,7 @@ end
|
|
28
28
|
puts ""
|
29
29
|
puts "after #{n} calls:"
|
30
30
|
GC.start
|
31
|
-
Vips::Object
|
31
|
+
Vips::Object.print_all
|
32
32
|
|
33
33
|
puts ""
|
34
34
|
puts "shutting down:"
|
data/example/example3.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require "vips"
|
4
4
|
|
5
5
|
# this makes vips keep a list of all active objects
|
6
|
-
Vips
|
6
|
+
Vips.leak_set true
|
7
7
|
|
8
8
|
# disable the operation cache
|
9
9
|
# Vips::cache_set_max 0
|
10
10
|
|
11
11
|
# turn on debug logging
|
12
|
-
GLib
|
12
|
+
GLib.logger.level = Logger::DEBUG
|
13
13
|
|
14
|
-
|
14
|
+
10.times do |i|
|
15
15
|
puts "loop #{i} ..."
|
16
16
|
im = Vips::Image.new_from_file ARGV[0]
|
17
|
-
im = im.embed 100, 100, 3000, 3000, :
|
17
|
+
im = im.embed 100, 100, 3000, 3000, extend: :mirror
|
18
18
|
im.write_to_file "x.v"
|
19
19
|
end
|
data/example/example4.rb
CHANGED
data/example/example5.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require "vips"
|
4
4
|
|
5
5
|
# this makes vips keep a list of all active objects
|
6
6
|
# Vips::leak_set true
|
@@ -15,7 +15,7 @@ if ARGV.length < 2
|
|
15
15
|
raise "usage: #{$PROGRAM_NAME}: input-file output-file"
|
16
16
|
end
|
17
17
|
|
18
|
-
im = Vips::Image.new_from_file ARGV[0], :
|
18
|
+
im = Vips::Image.new_from_file ARGV[0], access: :sequential
|
19
19
|
|
20
20
|
im *= [1, 2, 1]
|
21
21
|
|
@@ -23,8 +23,8 @@ im *= [1, 2, 1]
|
|
23
23
|
# make it ourselves
|
24
24
|
# if you are OK with scale=1, you can just pass the array directly to .conv()
|
25
25
|
mask = Vips::Image.new_from_array [[-1, -1, -1],
|
26
|
-
|
27
|
-
|
26
|
+
[-1, 16, -1],
|
27
|
+
[-1, -1, -1]], 8
|
28
28
|
im = im.conv mask
|
29
29
|
|
30
30
|
im.write_to_file ARGV[1]
|