ruby-vips 2.1.3 → 2.2.0
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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +12 -10
- data/CHANGELOG.md +19 -0
- data/README.md +32 -27
- data/TODO +1 -2
- data/VERSION +1 -1
- data/example/revalidate.rb +39 -0
- data/lib/vips/image.rb +70 -11
- data/lib/vips/methods.rb +565 -457
- data/lib/vips/mutableimage.rb +7 -0
- data/lib/vips/operation.rb +16 -2
- data/lib/vips/version.rb +1 -1
- data/lib/vips.rb +87 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13cfcbea0e56ad3823bf1da4e035884d934253c729d74da5f54c77e87e949c5a
|
4
|
+
data.tar.gz: ebd97fa16da17c0f932bccb49d21d5b1dcaa024e32ace5c3335f093b2043efea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7ff0c920fa2ccfe60e9b1762fce6efaa94413f5a68453156eaa7cad6a63cdbab3639ecc525c52cb11578684bc02e9868b7643ab4bc89a8f23905c7dae0b06c1
|
7
|
+
data.tar.gz: c258fc41dca1d105aa4617bac9a3092a8ea3ce7a2bf41f0ad37aac1baa3ebcdce9a3353a4be014b9748e8e141ca15916b67f789cb1fab76c8a5647832aa2efd0
|
data/.github/workflows/test.yml
CHANGED
@@ -38,15 +38,17 @@ jobs:
|
|
38
38
|
matrix:
|
39
39
|
os-version: [ 'ubuntu-20.04' ]
|
40
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
|
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
|
+
- '3.1'
|
51
|
+
- '3.2'
|
50
52
|
- jruby
|
51
53
|
fail-fast: true
|
52
54
|
|
@@ -54,7 +56,7 @@ jobs:
|
|
54
56
|
|
55
57
|
steps:
|
56
58
|
- name: Checkout code
|
57
|
-
uses: actions/checkout@
|
59
|
+
uses: actions/checkout@v3
|
58
60
|
|
59
61
|
- name: Set up Ruby
|
60
62
|
uses: ruby/setup-ruby@v1
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,25 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## Version 2.2.0 (2023-10-18)
|
6
|
+
|
7
|
+
* add `draw_point!` [jcupitt]
|
8
|
+
* add `Vips.tracked_*` for getting file and memory metrics [jeremy]
|
9
|
+
* add `Vips.cache_*` for getting cache settings [jeremy]
|
10
|
+
* add `Vips.vector?` to get/set SIMD status [jeremy]
|
11
|
+
* add `Vips.concurrency` to get/set threadpool size [jeremy]
|
12
|
+
* add `Vips.concurrency_default` to get the default threadpool size [jeremy]
|
13
|
+
* fix targetcustom spec test with libvips 8.13 [lucaskanashiro]
|
14
|
+
* add ruby 3.2 to CI [petergoldstein]
|
15
|
+
* update docs for libvips 8.15 [jcupitt]
|
16
|
+
|
17
|
+
## Version 2.1.4 (2021-10-28)
|
18
|
+
|
19
|
+
* `write_to_buffer` tries to use the new target API, then falls back to the old
|
20
|
+
buffer system [jcupitt]
|
21
|
+
* don't generate yard docs for deprecated args [jcupitt]
|
22
|
+
* add hyperbolic trig functions [jcupitt]
|
23
|
+
|
5
24
|
## Version 2.1.3 (2021-8-23)
|
6
25
|
|
7
26
|
* fix a gtype size error on win64 [danini-the-panini]
|
data/README.md
CHANGED
@@ -4,7 +4,10 @@
|
|
4
4
|
[](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
|
-
library](https://libvips.github.io/libvips).
|
7
|
+
library](https://libvips.github.io/libvips). It has been tested on
|
8
|
+
Linux, macOS and Windows, and with ruby 2, ruby 3 and jruby. It uses
|
9
|
+
[ruby-ffi](https://github.com/ffi/ffi) to call functions in the libvips
|
10
|
+
library.
|
8
11
|
|
9
12
|
libvips is a [demand-driven, horizontally
|
10
13
|
threaded](https://github.com/libvips/libvips/wiki/Why-is-libvips-quick)
|
@@ -14,34 +17,32 @@ memory](https://github.com/libvips/libvips/wiki/Speed-and-memory-use).
|
|
14
17
|
libvips is licensed under the [LGPL
|
15
18
|
2.1+](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html).
|
16
19
|
|
17
|
-
##
|
20
|
+
## Install on linux and macOS
|
18
21
|
|
19
|
-
|
22
|
+
Install the libvips binary with your package manager (eg. `apt install
|
23
|
+
libvips42` or perhaps `brew install vips`, see the [libvips install
|
24
|
+
instructions](https://libvips.github.io/libvips/install.html)) then install
|
25
|
+
this gem with:
|
20
26
|
|
21
|
-
|
22
|
-
|
23
|
-
|
27
|
+
```
|
28
|
+
gem install ruby-vips
|
29
|
+
```
|
24
30
|
|
25
|
-
|
31
|
+
Or include `gem "ruby-vips"` in your gemfile.
|
26
32
|
|
27
|
-
## Install
|
33
|
+
## Install on Windows
|
28
34
|
|
29
|
-
|
35
|
+
The gemspec will pull in the msys libvips for you, so all you need is:
|
30
36
|
|
31
37
|
```
|
32
|
-
|
38
|
+
gem install ruby-vips
|
33
39
|
```
|
34
40
|
|
35
|
-
|
41
|
+
Or include `gem "ruby-vips"` in your gemfile.
|
36
42
|
|
37
|
-
|
38
|
-
gem "ruby-vips"
|
39
|
-
```
|
43
|
+
Tested with the ruby and msys from choco, but others may work.
|
40
44
|
|
41
|
-
|
42
|
-
point to the libvips bin directory.
|
43
|
-
|
44
|
-
# Example
|
45
|
+
## Example
|
45
46
|
|
46
47
|
```ruby
|
47
48
|
require "vips"
|
@@ -68,19 +69,24 @@ im = im.conv mask, precision: :integer
|
|
68
69
|
im.write_to_file output_filename
|
69
70
|
```
|
70
71
|
|
71
|
-
|
72
|
+
## Documentation
|
73
|
+
|
74
|
+
There are [full API docs for ruby-vips on
|
75
|
+
rubydoc](https://www.rubydoc.info/gems/ruby-vips). This sometimes has issues
|
76
|
+
updating, so we have a [copy on the gh-pages for this site as
|
77
|
+
well](http://libvips.github.io/ruby-vips), which
|
78
|
+
should always work.
|
79
|
+
|
80
|
+
See the `Vips` section in the docs for a [tutorial introduction with
|
72
81
|
examples](https://www.rubydoc.info/gems/ruby-vips/Vips).
|
73
82
|
|
74
|
-
|
75
|
-
|
76
|
-
reference manual](https://libvips.github.io/libvips/API/current/) has a
|
77
|
-
complete explanation of every method.
|
83
|
+
The [libvips reference manual](https://libvips.github.io/libvips/API/current/)
|
84
|
+
has a complete explanation of every method.
|
78
85
|
|
79
|
-
The
|
80
|
-
[`example/`](https://github.com/libvips/ruby-vips/tree/master/example)
|
86
|
+
The [`example/`](https://github.com/libvips/ruby-vips/tree/master/example)
|
81
87
|
directory has some simple example programs.
|
82
88
|
|
83
|
-
|
89
|
+
## Benchmarks
|
84
90
|
|
85
91
|
The benchmark at [vips-benchmarks](https://github.com/jcupitt/vips-benchmarks)
|
86
92
|
loads a large image, crops, shrinks, sharpens and saves again, and repeats
|
@@ -101,4 +107,3 @@ rmagick.rb 788768
|
|
101
107
|
|
102
108
|
See also [benchmarks at the official libvips
|
103
109
|
website](https://github.com/libvips/libvips/wiki/Speed-and-memory-use).
|
104
|
-
|
data/TODO
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# demo the "revalidate" feature in libvips 8.15
|
4
|
+
|
5
|
+
require "fileutils"
|
6
|
+
require "vips"
|
7
|
+
|
8
|
+
if ARGV.length != 2
|
9
|
+
puts "usage: ./revalidate.rb IMAGE-FILE-1 IMAGE-FILE-2"
|
10
|
+
exit 1
|
11
|
+
end
|
12
|
+
|
13
|
+
if File.exist?("fred")
|
14
|
+
puts "file 'fred' exists, delete it first"
|
15
|
+
exit 1
|
16
|
+
end
|
17
|
+
|
18
|
+
puts "copying #{ARGV[0]} to fred ..."
|
19
|
+
FileUtils.cp(ARGV[0], "fred")
|
20
|
+
|
21
|
+
image1 = Vips::Image.new_from_file("fred")
|
22
|
+
puts "fred.width = #{image1.width}"
|
23
|
+
|
24
|
+
puts "copying #{ARGV[1]} to fred ..."
|
25
|
+
FileUtils.cp(ARGV[1], "fred")
|
26
|
+
|
27
|
+
puts "plain image open ..."
|
28
|
+
image2 = Vips::Image.new_from_file("fred")
|
29
|
+
puts "fred.width = #{image2.width}"
|
30
|
+
|
31
|
+
puts "opening with revalidate ..."
|
32
|
+
image2 = Vips::Image.new_from_file("fred", revalidate: true)
|
33
|
+
puts "fred.width = #{image2.width}"
|
34
|
+
|
35
|
+
puts "opening again, should get cached entry ..."
|
36
|
+
image2 = Vips::Image.new_from_file("fred")
|
37
|
+
puts "fred.width = #{image2.width}"
|
38
|
+
|
39
|
+
File.delete("fred")
|
data/lib/vips/image.rb
CHANGED
@@ -138,14 +138,14 @@ module Vips
|
|
138
138
|
image = image.cast :float
|
139
139
|
end
|
140
140
|
|
141
|
-
new_format = image.format == :double ? :dpcomplex : :complex
|
141
|
+
new_format = (image.format == :double) ? :dpcomplex : :complex
|
142
142
|
image = image.copy format: new_format, bands: image.bands / 2
|
143
143
|
end
|
144
144
|
|
145
145
|
image = block.call(image)
|
146
146
|
|
147
147
|
unless Image.complex? original_format
|
148
|
-
new_format = image.format == :dpcomplex ? :double : :float
|
148
|
+
new_format = (image.format == :dpcomplex) ? :double : :float
|
149
149
|
image = image.copy format: new_format, bands: image.bands * 2
|
150
150
|
end
|
151
151
|
|
@@ -623,11 +623,27 @@ module Vips
|
|
623
623
|
raise Vips::Error, "filename is nil" if format_string.nil?
|
624
624
|
filename = Vips.p2str(Vips.vips_filename_get_filename(format_string))
|
625
625
|
option_string = Vips.p2str(Vips.vips_filename_get_options(format_string))
|
626
|
-
saver = Vips.vips_foreign_find_save_buffer filename
|
627
|
-
raise Vips::Error if saver.nil?
|
628
626
|
|
629
|
-
|
630
|
-
|
627
|
+
# try to save with the new target API first, only fall back to the old
|
628
|
+
# buffer API if there's no target save for this filetype
|
629
|
+
saver = nil
|
630
|
+
if Vips.at_least_libvips?(8, 9)
|
631
|
+
Vips.vips_error_freeze
|
632
|
+
saver = Vips.vips_foreign_find_save_target filename
|
633
|
+
Vips.vips_error_thaw
|
634
|
+
end
|
635
|
+
|
636
|
+
if !saver.nil?
|
637
|
+
target = Vips::Target.new_to_memory
|
638
|
+
Vips::Operation.call saver, [self, target], opts, option_string
|
639
|
+
buffer = target.get("blob")
|
640
|
+
else
|
641
|
+
saver = Vips.vips_foreign_find_save_buffer filename
|
642
|
+
raise Vips::Error if saver.nil?
|
643
|
+
|
644
|
+
buffer = Vips::Operation.call saver, [self], opts, option_string
|
645
|
+
raise Vips::Error if buffer.nil?
|
646
|
+
end
|
631
647
|
|
632
648
|
write_gc
|
633
649
|
|
@@ -1434,6 +1450,48 @@ module Vips
|
|
1434
1450
|
math :atan
|
1435
1451
|
end
|
1436
1452
|
|
1453
|
+
# Return the hyperbolic sine of an image in radians.
|
1454
|
+
#
|
1455
|
+
# @return [Image] sine of each pixel
|
1456
|
+
def sinh
|
1457
|
+
math :sinh
|
1458
|
+
end
|
1459
|
+
|
1460
|
+
# Return the hyperbolic cosine of an image in radians.
|
1461
|
+
#
|
1462
|
+
# @return [Image] cosine of each pixel
|
1463
|
+
def cosh
|
1464
|
+
math :cosh
|
1465
|
+
end
|
1466
|
+
|
1467
|
+
# Return the hyperbolic tangent of an image in radians.
|
1468
|
+
#
|
1469
|
+
# @return [Image] tangent of each pixel
|
1470
|
+
def tanh
|
1471
|
+
math :tanh
|
1472
|
+
end
|
1473
|
+
|
1474
|
+
# Return the inverse hyperbolic sine of an image in radians.
|
1475
|
+
#
|
1476
|
+
# @return [Image] inverse sine of each pixel
|
1477
|
+
def asinh
|
1478
|
+
math :asinh
|
1479
|
+
end
|
1480
|
+
|
1481
|
+
# Return the inverse hyperbolic cosine of an image in radians.
|
1482
|
+
#
|
1483
|
+
# @return [Image] inverse cosine of each pixel
|
1484
|
+
def acosh
|
1485
|
+
math :acosh
|
1486
|
+
end
|
1487
|
+
|
1488
|
+
# Return the inverse hyperbolic tangent of an image in radians.
|
1489
|
+
#
|
1490
|
+
# @return [Image] inverse tangent of each pixel
|
1491
|
+
def atanh
|
1492
|
+
math :atanh
|
1493
|
+
end
|
1494
|
+
|
1437
1495
|
# Return the natural log of an image.
|
1438
1496
|
#
|
1439
1497
|
# @return [Image] natural log of each pixel
|
@@ -1616,8 +1674,8 @@ module Vips
|
|
1616
1674
|
|
1617
1675
|
method_args = introspect.method_args
|
1618
1676
|
required_output = introspect.required_output
|
1619
|
-
optional_input = introspect.
|
1620
|
-
optional_output = introspect.
|
1677
|
+
optional_input = introspect.doc_optional_input
|
1678
|
+
optional_output = introspect.doc_optional_output
|
1621
1679
|
|
1622
1680
|
print "# @!method "
|
1623
1681
|
print "self." unless introspect.member_x
|
@@ -1640,17 +1698,18 @@ module Vips
|
|
1640
1698
|
optional_input.each do |arg_name, details|
|
1641
1699
|
yard_name = details[:yard_name]
|
1642
1700
|
gtype = details[:gtype]
|
1701
|
+
rtype = gtype_to_ruby gtype
|
1643
1702
|
blurb = details[:blurb]
|
1644
1703
|
|
1645
|
-
puts "# @option opts [#{
|
1704
|
+
puts "# @option opts [#{rtype}] :#{yard_name} #{blurb}"
|
1646
1705
|
end
|
1647
1706
|
optional_output.each do |arg_name, details|
|
1648
1707
|
yard_name = details[:yard_name]
|
1649
1708
|
gtype = details[:gtype]
|
1709
|
+
rtype = gtype_to_ruby gtype
|
1650
1710
|
blurb = details[:blurb]
|
1651
1711
|
|
1652
|
-
|
1653
|
-
puts " Output #{blurb}"
|
1712
|
+
puts "# @option opts [#{rtype}] :#{yard_name} Output #{blurb}"
|
1654
1713
|
end
|
1655
1714
|
|
1656
1715
|
print "# @return ["
|