ruby-vips 2.0.17 → 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 +13 -0
- data/Gemfile +3 -1
- data/README.md +4 -4
- data/Rakefile +13 -21
- data/TODO +3 -6
- data/VERSION +1 -1
- data/example/annotate.rb +6 -6
- data/example/connection.rb +18 -9
- 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 +35 -36
- data/example/progress.rb +3 -3
- 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/ruby-vips.rb +1 -1
- data/lib/vips.rb +121 -75
- data/lib/vips/blend_mode.rb +29 -25
- data/lib/vips/connection.rb +4 -4
- data/lib/vips/gobject.rb +18 -11
- data/lib/vips/gvalue.rb +54 -54
- data/lib/vips/image.rb +232 -155
- data/lib/vips/interpolate.rb +3 -2
- data/lib/vips/methods.rb +165 -15
- data/lib/vips/mutableimage.rb +154 -0
- data/lib/vips/object.rb +84 -85
- data/lib/vips/operation.rb +161 -82
- data/lib/vips/region.rb +6 -6
- data/lib/vips/source.rb +11 -12
- data/lib/vips/sourcecustom.rb +7 -8
- data/lib/vips/target.rb +12 -13
- data/lib/vips/targetcustom.rb +9 -10
- data/lib/vips/version.rb +1 -1
- data/ruby-vips.gemspec +26 -22
- metadata +28 -48
- data/.rubocop.yml +0 -22
- data/.rubocop_todo.yml +0 -473
- data/.travis.yml +0 -57
- data/install-vips.sh +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b632e0e44fa32da791e46806757e9b6a1a9901d92e2de9b02e16682bc3f3e6b2
|
4
|
+
data.tar.gz: 5d3841b9a656d13003b1b2668c05ab89cf5b65c76a52dad070a67b9a6856fe60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11c11a729818aa279cf5a157cda6e810174da9089b9ae3a0e92b3c7e6080362dfca5a970b07f3881aa7f31e5aa4acf3cd1a9a05a2e3ef09dc86d7464fe8987fe
|
7
|
+
data.tar.gz: 41bae93d0c491699e0042acfe687bc86766af576c9ffe57da1c20a26de548e08c73c0d7685855a155630ed5d47a3a2e2e60f982df48df2a59d4a9f4bd6ccfd34
|
@@ -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,80 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
pull_request_target:
|
9
|
+
branches:
|
10
|
+
- master
|
11
|
+
|
12
|
+
env:
|
13
|
+
NOKOGIRI_USE_SYSTEM_LIBRARIES: true
|
14
|
+
SPEC_OPTS: '--backtrace'
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
lint:
|
18
|
+
name: Lint
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- name: Checkout code
|
23
|
+
uses: actions/checkout@v2
|
24
|
+
|
25
|
+
- name: Set up Ruby
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: '2.7'
|
29
|
+
bundler-cache: true
|
30
|
+
|
31
|
+
- name: Run standard Ruby linter
|
32
|
+
run: bundle exec standardrb --no-fix --fail-fast
|
33
|
+
|
34
|
+
test:
|
35
|
+
name: Functional testing
|
36
|
+
|
37
|
+
strategy:
|
38
|
+
matrix:
|
39
|
+
os-version: [ 'ubuntu-20.04' ]
|
40
|
+
ruby-version:
|
41
|
+
- 2.0
|
42
|
+
- 2.1
|
43
|
+
- 2.2
|
44
|
+
- 2.3
|
45
|
+
- 2.4
|
46
|
+
- 2.5
|
47
|
+
- 2.6
|
48
|
+
- 2.7
|
49
|
+
- 3.0
|
50
|
+
- jruby
|
51
|
+
fail-fast: true
|
52
|
+
|
53
|
+
runs-on: ${{ matrix.os-version }}
|
54
|
+
|
55
|
+
steps:
|
56
|
+
- name: Checkout code
|
57
|
+
uses: actions/checkout@v2
|
58
|
+
|
59
|
+
- name: Set up Ruby
|
60
|
+
uses: ruby/setup-ruby@v1
|
61
|
+
with:
|
62
|
+
ruby-version: ${{ matrix.ruby-version }}
|
63
|
+
bundler-cache: true
|
64
|
+
|
65
|
+
- name: Update apt
|
66
|
+
env:
|
67
|
+
DEBIAN_FRONTEND: noninteractive
|
68
|
+
run:
|
69
|
+
sudo apt-get update -qq -o Acquire::Retries=3
|
70
|
+
|
71
|
+
- name: Install libvips
|
72
|
+
env:
|
73
|
+
DEBIAN_FRONTEND: noninteractive
|
74
|
+
run:
|
75
|
+
# we only need the library
|
76
|
+
sudo apt-get install --fix-missing -qq -o Acquire::Retries=3
|
77
|
+
libvips
|
78
|
+
|
79
|
+
- name: Run Tests
|
80
|
+
run: 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/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,19 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## Version 2.1.0 (2021-3-8)
|
6
|
+
|
7
|
+
* add "mutate" system [jcupitt]
|
8
|
+
* better behaviour with some nil parameters [jcupitt]
|
9
|
+
* revise gemspec [jcupitt]
|
10
|
+
* allow symbols for Interpolate.new [noraj]
|
11
|
+
* update docs for 8.10, fix minor doc formatting issues [jcupitt]
|
12
|
+
* `new_from_array` checks array argument more carefully [dkam]
|
13
|
+
* add `new_from_memory` and `new_from_memory_copy` [ankane]
|
14
|
+
* jruby added to CI testing [pftg]
|
15
|
+
* switch to github actions for CI [pftg]
|
16
|
+
* remove rubocop, revise formatting for standardrb [pftg]
|
17
|
+
|
5
18
|
## Version 2.0.17 (2019-10-29)
|
6
19
|
|
7
20
|
* install msys2 libvips on Windows [larskanis]
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# ruby-vips
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/ruby-vips.svg)](https://badge.fury.io/rb/ruby-vips)
|
4
|
-
[![
|
4
|
+
[![Test](https://github.com/libvips/ruby-vips/workflows/Test/badge.svg)](https://github.com/libvips/ruby-vips/actions?query=workflow%3ATest)
|
5
5
|
|
6
6
|
This gem is a Ruby binding for the [libvips image processing
|
7
7
|
library](https://libvips.github.io/libvips).
|
@@ -21,7 +21,7 @@ and because it doesn't need to keep entire images in memory, it's light.
|
|
21
21
|
|
22
22
|
* [ruby-ffi](https://github.com/ffi/ffi) 1.9 or later
|
23
23
|
|
24
|
-
* Ruby 2.0+, JRuby
|
24
|
+
* Ruby 2.0+, JRuby
|
25
25
|
|
26
26
|
## Install
|
27
27
|
|
@@ -34,7 +34,7 @@ $ gem install ruby-vips
|
|
34
34
|
or include it in `Gemfile`:
|
35
35
|
|
36
36
|
```ruby
|
37
|
-
gem
|
37
|
+
gem "ruby-vips"
|
38
38
|
```
|
39
39
|
|
40
40
|
On Windows, you'll need to set the `RUBY_DLL_PATH` environment variable to
|
@@ -43,7 +43,7 @@ point to the libvips bin directory.
|
|
43
43
|
# Example
|
44
44
|
|
45
45
|
```ruby
|
46
|
-
require
|
46
|
+
require "vips"
|
47
47
|
|
48
48
|
im = Vips::Image.new_from_file filename
|
49
49
|
|
data/Rakefile
CHANGED
@@ -1,35 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
1
|
+
require "bundler/gem_tasks"
|
4
2
|
|
5
3
|
begin
|
6
4
|
Bundler.setup(:default, :development)
|
7
5
|
rescue Bundler::BundlerError => e
|
8
|
-
|
9
|
-
|
6
|
+
warn e.message
|
7
|
+
warn "Run `bundle install` to install missing gems"
|
10
8
|
exit e.status_code
|
11
9
|
end
|
12
10
|
|
13
|
-
require
|
11
|
+
require "rake"
|
14
12
|
|
15
|
-
require
|
16
|
-
require
|
13
|
+
require "rspec/core"
|
14
|
+
require "rspec/core/rake_task"
|
17
15
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
18
|
-
spec.pattern = FileList[
|
16
|
+
spec.pattern = FileList["spec/**/*_spec.rb"]
|
19
17
|
end
|
20
18
|
|
21
|
-
task :
|
22
|
-
|
23
|
-
require "github/markup"
|
24
|
-
require "redcarpet"
|
25
|
-
require "yard"
|
26
|
-
require "yard/rake/yardoc_task"
|
19
|
+
task default: :spec
|
27
20
|
|
28
|
-
|
29
|
-
|
21
|
+
unless RUBY_PLATFORM.include?("java")
|
22
|
+
require "github/markup"
|
23
|
+
require "yard"
|
24
|
+
require "yard/rake/yardoc_task"
|
30
25
|
|
31
|
-
|
32
|
-
if Gem.ruby_version >= Gem::Version.new("2.2.0")
|
33
|
-
require 'rubocop/rake_task'
|
34
|
-
RuboCop::RakeTask.new
|
26
|
+
YARD::Rake::YardocTask.new
|
35
27
|
end
|
data/TODO
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
- Lint.
|
11
11
|
|
12
|
-
bundle exec
|
12
|
+
bundle exec standardrb
|
13
13
|
|
14
14
|
- Reinstall local copy of gem after a change.
|
15
15
|
|
@@ -28,19 +28,16 @@
|
|
28
28
|
|
29
29
|
cd lib/vips
|
30
30
|
ruby > methods.rb
|
31
|
-
require
|
31
|
+
require "vips"; Vips::Yard.generate
|
32
32
|
^D
|
33
33
|
|
34
|
-
- Regenerate `.rubocop_todo.yml`.
|
35
|
-
|
36
|
-
bundle exec rubocop --auto-gen-config
|
37
|
-
|
38
34
|
- Regenerate docs.
|
39
35
|
|
40
36
|
bundle exec rake yard
|
41
37
|
|
42
38
|
- Push new gem to rubygems, tag repository with version.
|
43
39
|
|
40
|
+
gem2.5 signin --otp 111111 / enter username and passwd
|
44
41
|
bundle exec rake release
|
45
42
|
|
46
43
|
There's an invisible prompt for the authenticator code. Enter eg. 123456,
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0
|
1
|
+
2.1.0
|
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]
|
data/example/connection.rb
CHANGED
@@ -1,17 +1,26 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
require
|
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])
|
4
9
|
|
5
|
-
file = File.open ARGV[0], "rb"
|
6
10
|
source = Vips::SourceCustom.new
|
7
|
-
source.on_read
|
8
|
-
|
9
|
-
|
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
|
10
19
|
|
11
|
-
|
20
|
+
byte_target = File.open ARGV[1], "wb"
|
12
21
|
target = Vips::TargetCustom.new
|
13
|
-
target.on_write { |chunk|
|
14
|
-
target.on_finish {
|
22
|
+
target.on_write { |chunk| byte_target.write(chunk) }
|
23
|
+
target.on_finish { byte_target.close }
|
15
24
|
|
16
25
|
image = Vips::Image.new_from_source source, "", access: :sequential
|
17
|
-
image.write_to_target target, ".
|
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]
|