ruby-vips 2.0.17 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +42 -0
  3. data/.github/workflows/test.yml +80 -0
  4. data/.standard.yml +17 -0
  5. data/.yardopts +0 -1
  6. data/CHANGELOG.md +26 -0
  7. data/Gemfile +3 -1
  8. data/README.md +12 -11
  9. data/Rakefile +13 -21
  10. data/TODO +4 -8
  11. data/VERSION +1 -1
  12. data/example/annotate.rb +6 -6
  13. data/example/connection.rb +18 -9
  14. data/example/daltonize8.rb +6 -6
  15. data/example/draw_lines.rb +30 -0
  16. data/example/example1.rb +4 -4
  17. data/example/example2.rb +6 -6
  18. data/example/example3.rb +5 -5
  19. data/example/example4.rb +2 -2
  20. data/example/example5.rb +4 -4
  21. data/example/inheritance_with_refcount.rb +46 -39
  22. data/example/progress.rb +3 -3
  23. data/example/thumb.rb +6 -6
  24. data/example/trim8.rb +1 -1
  25. data/example/watermark.rb +2 -2
  26. data/example/wobble.rb +1 -1
  27. data/lib/ruby-vips.rb +1 -1
  28. data/lib/vips.rb +127 -76
  29. data/lib/vips/blend_mode.rb +29 -25
  30. data/lib/vips/connection.rb +4 -4
  31. data/lib/vips/gobject.rb +18 -11
  32. data/lib/vips/gvalue.rb +54 -54
  33. data/lib/vips/image.rb +289 -165
  34. data/lib/vips/interpolate.rb +3 -2
  35. data/lib/vips/methods.rb +484 -107
  36. data/lib/vips/mutableimage.rb +173 -0
  37. data/lib/vips/object.rb +86 -93
  38. data/lib/vips/operation.rb +161 -82
  39. data/lib/vips/region.rb +6 -6
  40. data/lib/vips/source.rb +11 -12
  41. data/lib/vips/sourcecustom.rb +7 -8
  42. data/lib/vips/target.rb +12 -13
  43. data/lib/vips/targetcustom.rb +9 -10
  44. data/lib/vips/version.rb +1 -1
  45. data/ruby-vips.gemspec +26 -22
  46. metadata +29 -49
  47. data/.rubocop.yml +0 -22
  48. data/.rubocop_todo.yml +0 -473
  49. data/.travis.yml +0 -57
  50. data/install-vips.sh +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e63754294a1cbf0c65135dca3b377085616a6e386fb75d6442937fccb9c4c5a
4
- data.tar.gz: d885bef5779402c0fbdc100635d8f26794d4d7394c97ac4eb1829343aaa5d636
3
+ metadata.gz: 5e9c2a25819da8d93bb3cd90e9c409d475090b789bc2c1f4e30389ad665cb579
4
+ data.tar.gz: 3d92ec1b0020802e05df6c632c135c8bae07478afa44a76ef2b8d3c9e5466563
5
5
  SHA512:
6
- metadata.gz: 2c52c6e54dc34dba9d01eb39dafc9e8d4132f3242d0a30ec89ea661c0b6d1be424ba6287398f13e697069e3a3d0f07e175f28f2f0f0b51caaed9cea8dc21aeee
7
- data.tar.gz: 72e1116ca589860cbe30a3f6b89a7ca07a9d594b2be972a1cedad779a255a8d9418c5f9d472c90c1be63e76e518972d2ad48c73d31472aa8cf070ce668f29050
6
+ metadata.gz: 1af7c18265746e1553e321bc2410fd37d8c1e627306bf347768893c5d0a6fa57f4663ec80c7c2d877c3a49382bfb49b45759c4af3ee181717f4eecc78f66bab4
7
+ data.tar.gz: 792c89c07bda9f21e22e0938db16f9182b055b803d41dde4846f804dddc7d3f1c44469ced01f1fba82982b06c204cf22e93ed6510bdb6cac4a061193e085c6b7
@@ -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
@@ -1,2 +1 @@
1
- --markup-provider=redcarpet
2
1
  --markup=markdown
data/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## Version 2.1.3 (2021-8-23)
6
+
7
+ * fix a gtype size error on win64 [danini-the-panini]
8
+
9
+ ## Version 2.1.2 (2021-5-3)
10
+
11
+ * allow `FFI::Pointer` as an argument to `new_from_memory` etc. [sled]
12
+
13
+ ## Version 2.1.1 (2021-5-3)
14
+
15
+ * fix "mutate" with libvips 8.9 [jcupitt]
16
+ * update autodocs for libvips 8.11 [jcupitt]
17
+
18
+ ## Version 2.1.0 (2021-3-8)
19
+
20
+ * add "mutate" system [jcupitt]
21
+ * better behaviour with some nil parameters [jcupitt]
22
+ * revise gemspec [jcupitt]
23
+ * allow symbols for Interpolate.new [noraj]
24
+ * update docs for 8.10, fix minor doc formatting issues [jcupitt]
25
+ * `new_from_array` checks array argument more carefully [dkam]
26
+ * add `new_from_memory` and `new_from_memory_copy` [ankane]
27
+ * jruby added to CI testing [pftg]
28
+ * switch to github actions for CI [pftg]
29
+ * remove rubocop, revise formatting for standardrb [pftg]
30
+
5
31
  ## Version 2.0.17 (2019-10-29)
6
32
 
7
33
  * install msys2 libvips on Windows [larskanis]
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # all gems are handled by .gemspec (since this repo is for a gem)
4
4
  gemspec
5
+
6
+ gem "github-markup"
data/README.md CHANGED
@@ -1,17 +1,18 @@
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
- [![Build Status](https://travis-ci.org/libvips/ruby-vips.svg?branch=master)](https://travis-ci.org/libvips/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
5
 
6
6
  This gem is a Ruby binding for the [libvips image processing
7
7
  library](https://libvips.github.io/libvips).
8
8
 
9
- Programs that use `ruby-vips` don't manipulate images directly, instead
10
- they create pipelines of image processing operations building on a source
11
- image. When the end of the pipe is connected to a destination, the whole
12
- pipeline executes at once, streaming the image in parallel from source to
13
- destination a section at a time. Because `ruby-vips` is parallel, it's quick,
14
- and because it doesn't need to keep entire images in memory, it's light.
9
+ libvips is a [demand-driven, horizontally
10
+ threaded](https://github.com/libvips/libvips/wiki/Why-is-libvips-quick)
11
+ image processing library. Compared to similar
12
+ libraries, [libvips runs quickly and uses little
13
+ memory](https://github.com/libvips/libvips/wiki/Speed-and-memory-use).
14
+ libvips is licensed under the [LGPL
15
+ 2.1+](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html).
15
16
 
16
17
  ## Requirements
17
18
 
@@ -21,11 +22,11 @@ and because it doesn't need to keep entire images in memory, it's light.
21
22
 
22
23
  * [ruby-ffi](https://github.com/ffi/ffi) 1.9 or later
23
24
 
24
- * Ruby 2.0+, JRuby should work
25
+ * Ruby 2.0+, JRuby
25
26
 
26
27
  ## Install
27
28
 
28
- It's just:
29
+ [Install libvips](https://libvips.github.io/libvips/install.html), then:
29
30
 
30
31
  ```
31
32
  $ gem install ruby-vips
@@ -34,7 +35,7 @@ $ gem install ruby-vips
34
35
  or include it in `Gemfile`:
35
36
 
36
37
  ```ruby
37
- gem 'ruby-vips'
38
+ gem "ruby-vips"
38
39
  ```
39
40
 
40
41
  On Windows, you'll need to set the `RUBY_DLL_PATH` environment variable to
@@ -43,7 +44,7 @@ point to the libvips bin directory.
43
44
  # Example
44
45
 
45
46
  ```ruby
46
- require 'vips'
47
+ require "vips"
47
48
 
48
49
  im = Vips::Image.new_from_file filename
49
50
 
data/Rakefile CHANGED
@@ -1,35 +1,27 @@
1
- # encoding: utf-8
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
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
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 'rake'
11
+ require "rake"
14
12
 
15
- require 'rspec/core'
16
- require 'rspec/core/rake_task'
13
+ require "rspec/core"
14
+ require "rspec/core/rake_task"
17
15
  RSpec::Core::RakeTask.new(:spec) do |spec|
18
- spec.pattern = FileList['spec/**/*_spec.rb']
16
+ spec.pattern = FileList["spec/**/*_spec.rb"]
19
17
  end
20
18
 
21
- task :default => :spec
22
-
23
- require "github/markup"
24
- require "redcarpet"
25
- require "yard"
26
- require "yard/rake/yardoc_task"
19
+ task default: :spec
27
20
 
28
- YARD::Rake::YardocTask.new do |yard|
29
- end
21
+ unless RUBY_PLATFORM.include?("java")
22
+ require "github/markup"
23
+ require "yard"
24
+ require "yard/rake/yardoc_task"
30
25
 
31
- # RuboCop requires Ruby >= 2.2
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 rake rubocop
12
+ bundle exec standardrb
13
13
 
14
14
  - Reinstall local copy of gem after a change.
15
15
 
@@ -28,21 +28,17 @@
28
28
 
29
29
  cd lib/vips
30
30
  ruby > methods.rb
31
- require 'vips'; Vips::Yard.generate
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
+ gem signin --otp 111111
44
41
  bundle exec rake release
45
42
 
46
- There's an invisible prompt for the authenticator code. Enter eg. 123456,
47
- press return and the upload should work.
43
+ The otp is from authy / google authenticator / etc.
48
44
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.17
1
+ 2.1.3
data/example/annotate.rb CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- require 'vips'
3
+ require "vips"
4
4
 
5
- im = Vips::Image.new_from_file ARGV[0], :access => :sequential
5
+ im = Vips::Image.new_from_file ARGV[0], access: :sequential
6
6
 
7
- left_text = Vips::Image.text "left corner", :dpi => 300
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", :dpi => 300
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], :blend => true)
13
+ footer = (left | right).ifthenelse(0, [255, 0, 0], blend: true)
14
14
 
15
- im = im.insert footer, 0, im.height, :expand => true
15
+ im = im.insert footer, 0, im.height, expand: true
16
16
 
17
17
  im.write_to_file ARGV[1]
@@ -1,17 +1,26 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- require 'vips'
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 { |length| file.read length }
8
- # this method is optional
9
- # source.on_seek { |offset, whence| file.seek(offset, whence) }
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
- dest = File.open ARGV[1], "wb"
20
+ byte_target = File.open ARGV[1], "wb"
12
21
  target = Vips::TargetCustom.new
13
- target.on_write { |chunk| dest.write(chunk) }
14
- target.on_finish { dest.close }
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, ".png"
26
+ image.write_to_target target, ".jpg"
@@ -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 'vips'
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, :n => 3
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 :embedded => true, :pcs => :xyz
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 = im + err.recomb([[0, 0, 0],
65
- [0.7, 1, 0],
66
- [0.7, 0, 1]])
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