ruby-vips 2.1.4 → 2.2.4
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/dependabot.yml +6 -0
- data/.github/workflows/test.yml +16 -31
- data/CHANGELOG.md +33 -0
- data/README.md +18 -18
- data/TODO +1 -2
- data/VERSION +1 -1
- data/example/revalidate.rb +39 -0
- data/lib/vips/image.rb +15 -8
- data/lib/vips/interpolate.rb +3 -3
- data/lib/vips/methods.rb +679 -365
- data/lib/vips/mutableimage.rb +8 -1
- data/lib/vips/object.rb +1 -3
- data/lib/vips/operation.rb +16 -11
- data/lib/vips/region.rb +3 -3
- data/lib/vips/sourcecustom.rb +1 -1
- data/lib/vips/targetcustom.rb +1 -1
- data/lib/vips/version.rb +1 -1
- data/lib/vips.rb +145 -7
- data/ruby-vips.gemspec +1 -0
- metadata +19 -6
data/lib/vips/mutableimage.rb
CHANGED
@@ -58,7 +58,7 @@ module Vips
|
|
58
58
|
# See also the comment on set_type! before changing this.
|
59
59
|
pointer = copy_image.ptr
|
60
60
|
::GObject.g_object_ref pointer
|
61
|
-
super
|
61
|
+
super(pointer)
|
62
62
|
|
63
63
|
# and save the copy ready for when we finish mutating
|
64
64
|
@image = copy_image
|
@@ -96,6 +96,13 @@ module Vips
|
|
96
96
|
Vips::Operation.call name.to_s, [self, *args], options
|
97
97
|
end
|
98
98
|
|
99
|
+
# Draw a point on an image.
|
100
|
+
#
|
101
|
+
# See {Image#draw_rect}.
|
102
|
+
def draw_point! ink, left, top, **opts
|
103
|
+
draw_rect! ink, left, top, 1, 1, **opts
|
104
|
+
end
|
105
|
+
|
99
106
|
# Create a metadata item on an image of the specifed type. Ruby types
|
100
107
|
# are automatically transformed into the matching glib type (eg.
|
101
108
|
# {GObject::GINT_TYPE}), if possible.
|
data/lib/vips/object.rb
CHANGED
@@ -9,9 +9,6 @@ require "ffi"
|
|
9
9
|
module Vips
|
10
10
|
private
|
11
11
|
|
12
|
-
# debugging support
|
13
|
-
attach_function :vips_object_print_all, [], :void
|
14
|
-
|
15
12
|
# we must init these by hand, since they are usually made on first image
|
16
13
|
# create
|
17
14
|
attach_function :vips_band_format_get_type, [], :GType
|
@@ -337,6 +334,7 @@ module Vips
|
|
337
334
|
ArgumentClassPtr.ptr, ArgumentInstancePtr.ptr],
|
338
335
|
:int
|
339
336
|
|
337
|
+
# debugging support
|
340
338
|
attach_function :vips_object_print_all, [], :void
|
341
339
|
|
342
340
|
attach_function :vips_object_set_from_string, [:pointer, :string], :int
|
data/lib/vips/operation.rb
CHANGED
@@ -151,7 +151,7 @@ module Vips
|
|
151
151
|
flags = details[:flags]
|
152
152
|
gtype = details[:gtype]
|
153
153
|
|
154
|
-
details[:yard_name] = arg_name == "in" ? "im" : arg_name
|
154
|
+
details[:yard_name] = (arg_name == "in") ? "im" : arg_name
|
155
155
|
pspec = @op.get_pspec arg_name
|
156
156
|
details[:blurb] = GObject.g_param_spec_get_blurb pspec
|
157
157
|
|
@@ -218,7 +218,7 @@ module Vips
|
|
218
218
|
raise Vips::Error if value.null?
|
219
219
|
end
|
220
220
|
|
221
|
-
super
|
221
|
+
super
|
222
222
|
end
|
223
223
|
|
224
224
|
def build
|
@@ -283,7 +283,7 @@ module Vips
|
|
283
283
|
value = value.map { |x| Operation.imageize match_image, x }
|
284
284
|
end
|
285
285
|
|
286
|
-
super
|
286
|
+
super(name, value)
|
287
287
|
end
|
288
288
|
|
289
289
|
public
|
@@ -440,14 +440,12 @@ module Vips
|
|
440
440
|
end
|
441
441
|
end
|
442
442
|
|
443
|
-
#
|
444
|
-
|
443
|
+
# dedupe all input references here
|
444
|
+
deduped_references = Set.new
|
445
445
|
|
446
446
|
add_reference = lambda do |x|
|
447
447
|
if x.is_a?(Vips::Image)
|
448
|
-
x.references
|
449
|
-
references << i
|
450
|
-
end
|
448
|
+
deduped_references.merge x.references
|
451
449
|
end
|
452
450
|
false
|
453
451
|
end
|
@@ -482,20 +480,27 @@ module Vips
|
|
482
480
|
|
483
481
|
op = op.build
|
484
482
|
|
483
|
+
# we need an array of references for output objects
|
484
|
+
references = deduped_references.to_a
|
485
|
+
|
485
486
|
# attach all input refs to output x
|
486
487
|
set_reference = lambda do |x|
|
488
|
+
# stop early if there are no refs to attach
|
489
|
+
return true if references == []
|
490
|
+
|
487
491
|
if x.is_a? Vips::Image
|
488
|
-
x.references
|
492
|
+
references.each { |i| x.references << i }
|
489
493
|
end
|
494
|
+
|
490
495
|
false
|
491
496
|
end
|
492
497
|
|
493
498
|
# get all required results
|
494
499
|
result = []
|
495
500
|
required_output.each do |details|
|
496
|
-
value = details[:arg_name]
|
501
|
+
value = op.get(details[:arg_name])
|
497
502
|
flat_find value, &set_reference
|
498
|
-
result <<
|
503
|
+
result << value
|
499
504
|
end
|
500
505
|
|
501
506
|
# fetch all optional ones
|
data/lib/vips/region.rb
CHANGED
@@ -44,10 +44,10 @@ module Vips
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def initialize(name)
|
47
|
-
|
48
|
-
raise Vips::Error if
|
47
|
+
pointer = Vips.vips_region_new name
|
48
|
+
raise Vips::Error if pointer.null?
|
49
49
|
|
50
|
-
super
|
50
|
+
super(pointer)
|
51
51
|
end
|
52
52
|
|
53
53
|
def width
|
data/lib/vips/sourcecustom.rb
CHANGED
data/lib/vips/targetcustom.rb
CHANGED
data/lib/vips/version.rb
CHANGED
data/lib/vips.rb
CHANGED
@@ -33,6 +33,30 @@ def library_name(name, abi_number)
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
# we can sometimes get dependent libraries from libvips -- either the platform
|
37
|
+
# will open dependencies for us automatically, or the libvips binary has been
|
38
|
+
# built to includes all main dependencies (common on windows, can happen
|
39
|
+
# elsewhere)
|
40
|
+
#
|
41
|
+
# we must get glib functions from libvips if we can, since it will be the
|
42
|
+
# one that libvips itself is using, and they will share runtime types
|
43
|
+
module Vips
|
44
|
+
extend FFI::Library
|
45
|
+
|
46
|
+
ffi_lib library_name("vips", 42)
|
47
|
+
|
48
|
+
begin
|
49
|
+
attach_function :g_malloc, [:size_t], :pointer
|
50
|
+
@@is_unified = true
|
51
|
+
rescue FFI::NotFoundError
|
52
|
+
@@is_unified = false
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.unified?
|
56
|
+
@@is_unified
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
36
60
|
module GLib
|
37
61
|
class << self
|
38
62
|
attr_accessor :logger
|
@@ -42,7 +66,11 @@ module GLib
|
|
42
66
|
|
43
67
|
extend FFI::Library
|
44
68
|
|
45
|
-
|
69
|
+
if Vips.unified?
|
70
|
+
ffi_lib library_name("vips", 42)
|
71
|
+
else
|
72
|
+
ffi_lib library_name("glib-2.0", 0)
|
73
|
+
end
|
46
74
|
|
47
75
|
attach_function :g_malloc, [:size_t], :pointer
|
48
76
|
|
@@ -134,7 +162,11 @@ end
|
|
134
162
|
module GObject
|
135
163
|
extend FFI::Library
|
136
164
|
|
137
|
-
|
165
|
+
if Vips.unified?
|
166
|
+
ffi_lib library_name("vips", 42)
|
167
|
+
else
|
168
|
+
ffi_lib library_name("gobject-2.0", 0)
|
169
|
+
end
|
138
170
|
|
139
171
|
# we can't just use ulong, windows has different int sizing rules
|
140
172
|
if FFI::Platform::ADDRESS_SIZE == 64
|
@@ -568,9 +600,7 @@ require "vips/gvalue"
|
|
568
600
|
# {Image#median}.
|
569
601
|
|
570
602
|
module Vips
|
571
|
-
|
572
|
-
|
573
|
-
ffi_lib library_name("vips", 42)
|
603
|
+
# we've already opened the libvips library
|
574
604
|
|
575
605
|
LOG_DOMAIN = "VIPS"
|
576
606
|
GLib.set_log_domain LOG_DOMAIN
|
@@ -625,7 +655,12 @@ module Vips
|
|
625
655
|
|
626
656
|
attach_function :vips_leak_set, [:int], :void
|
627
657
|
attach_function :vips_vector_set_enabled, [:int], :void
|
658
|
+
attach_function :vips_vector_isenabled, [], :int
|
628
659
|
attach_function :vips_concurrency_set, [:int], :void
|
660
|
+
attach_function :vips_concurrency_get, [], :int
|
661
|
+
|
662
|
+
# Track the original default concurrency so we can reset to it.
|
663
|
+
DEFAULT_CONCURRENCY = vips_concurrency_get
|
629
664
|
|
630
665
|
# vips_foreign_get_suffixes was added in libvips 8.8
|
631
666
|
begin
|
@@ -640,20 +675,66 @@ module Vips
|
|
640
675
|
vips_leak_set((leak ? 1 : 0))
|
641
676
|
end
|
642
677
|
|
678
|
+
attach_function :vips_tracked_get_mem, [], :int
|
679
|
+
attach_function :vips_tracked_get_mem_highwater, [], :int
|
680
|
+
attach_function :vips_tracked_get_allocs, [], :int
|
681
|
+
attach_function :vips_tracked_get_files, [], :int
|
682
|
+
attach_function :vips_cache_get_max, [], :int
|
683
|
+
attach_function :vips_cache_get_max_mem, [], :int
|
684
|
+
attach_function :vips_cache_get_max_files, [], :int
|
643
685
|
attach_function :vips_cache_set_max, [:int], :void
|
644
686
|
attach_function :vips_cache_set_max_mem, [:int], :void
|
645
687
|
attach_function :vips_cache_set_max_files, [:int], :void
|
688
|
+
attach_function :vips_cache_print, [], :void
|
689
|
+
attach_function :vips_cache_drop_all, [], :void
|
690
|
+
|
691
|
+
# Get the number of bytes currently allocated via vips_malloc.
|
692
|
+
def self.tracked_mem
|
693
|
+
vips_tracked_get_mem
|
694
|
+
end
|
695
|
+
|
696
|
+
# Get the greatest number of bytes ever actively allocated via vips_malloc.
|
697
|
+
def self.tracked_mem_highwater
|
698
|
+
vips_tracked_get_mem_highwater
|
699
|
+
end
|
700
|
+
|
701
|
+
# Get the number of active allocations.
|
702
|
+
def self.tracked_allocs
|
703
|
+
vips_tracked_get_allocs
|
704
|
+
end
|
705
|
+
|
706
|
+
# Get the number of open files.
|
707
|
+
def self.tracked_files
|
708
|
+
vips_tracked_get_files
|
709
|
+
end
|
710
|
+
|
711
|
+
# Get the maximum number of operations that libvips should cache.
|
712
|
+
def self.cache_max
|
713
|
+
vips_cache_get_max
|
714
|
+
end
|
715
|
+
|
716
|
+
# Get the maximum amount of memory that libvips uses for the operation cache.
|
717
|
+
def self.cache_max_mem
|
718
|
+
vips_cache_get_max_mem
|
719
|
+
end
|
720
|
+
|
721
|
+
# Get the maximum number of files libvips keeps open in the operation cache.
|
722
|
+
def self.cache_max_files
|
723
|
+
vips_cache_get_max_files
|
724
|
+
end
|
646
725
|
|
647
726
|
# Set the maximum number of operations that libvips should cache. Set 0 to
|
648
727
|
# disable the operation cache. The default is 1000.
|
649
728
|
def self.cache_set_max size
|
650
729
|
vips_cache_set_max size
|
730
|
+
cache_max
|
651
731
|
end
|
652
732
|
|
653
733
|
# Set the maximum amount of memory that libvips should use for the operation
|
654
734
|
# cache. Set 0 to disable the operation cache. The default is 100mb.
|
655
735
|
def self.cache_set_max_mem size
|
656
736
|
vips_cache_set_max_mem size
|
737
|
+
cache_max_mem
|
657
738
|
end
|
658
739
|
|
659
740
|
# Set the maximum number of files libvips should keep open in the
|
@@ -661,12 +742,43 @@ module Vips
|
|
661
742
|
# 100.
|
662
743
|
def self.cache_set_max_files size
|
663
744
|
vips_cache_set_max_files size
|
745
|
+
cache_max_files
|
746
|
+
end
|
747
|
+
|
748
|
+
# Print the libvips operation cache to stdout. Handy for debugging.
|
749
|
+
def self.cache_print # :nodoc:
|
750
|
+
vips_cache_print
|
751
|
+
end
|
752
|
+
|
753
|
+
# Drop the libvips operation cache. Handy for leak tracking.
|
754
|
+
def self.cache_drop_all # :nodoc:
|
755
|
+
vips_cache_drop_all
|
756
|
+
end
|
757
|
+
|
758
|
+
# Get the size of libvips worker pools. Defaults to the VIPS_CONCURRENCY env
|
759
|
+
# var or the number of hardware threads on your computer.
|
760
|
+
def self.concurrency
|
761
|
+
vips_concurrency_get
|
762
|
+
end
|
763
|
+
|
764
|
+
# Get the default size of libvips worker pools.
|
765
|
+
def self.concurrency_default
|
766
|
+
DEFAULT_CONCURRENCY
|
664
767
|
end
|
665
768
|
|
666
|
-
# Set the size of
|
667
|
-
#
|
769
|
+
# Set the size of each libvips worker pool. Max 1024 threads. Set to 1 to
|
770
|
+
# disable threading. Set to 0 or nil to reset to default.
|
668
771
|
def self.concurrency_set n
|
772
|
+
n = DEFAULT_CONCURRENCY if n.to_i == 0
|
669
773
|
vips_concurrency_set n
|
774
|
+
concurrency
|
775
|
+
end
|
776
|
+
|
777
|
+
# Whether SIMD and the run-time compiler are enabled. This can give a nice
|
778
|
+
# speed-up, but can also be unstable on some systems or with some versions
|
779
|
+
# of the run-time compiler.
|
780
|
+
def self.vector?
|
781
|
+
vips_vector_isenabled == 1
|
670
782
|
end
|
671
783
|
|
672
784
|
# Enable or disable SIMD and the run-time compiler. This can give a nice
|
@@ -674,6 +786,7 @@ module Vips
|
|
674
786
|
# of the run-time compiler.
|
675
787
|
def self.vector_set enabled
|
676
788
|
vips_vector_set_enabled(enabled ? 1 : 0)
|
789
|
+
vector?
|
677
790
|
end
|
678
791
|
|
679
792
|
# Deprecated compatibility function.
|
@@ -696,6 +809,31 @@ module Vips
|
|
696
809
|
major > x || (major == x && minor >= y)
|
697
810
|
end
|
698
811
|
|
812
|
+
if at_least_libvips?(8, 13)
|
813
|
+
attach_function :vips_block_untrusted_set, [:int], :void
|
814
|
+
attach_function :vips_operation_block_set, [:string, :int], :void
|
815
|
+
|
816
|
+
# Block/unblock all untrusted operations from running.
|
817
|
+
# Use `vips -l` at the command-line to see the class hierarchy and which operations are marked as untrusted.
|
818
|
+
def self.block_untrusted(state)
|
819
|
+
vips_block_untrusted_set(state ? 1 : 0)
|
820
|
+
end
|
821
|
+
|
822
|
+
# Block/unblock all operations in the libvips class hierarchy at specified *operation_name* and below.
|
823
|
+
#
|
824
|
+
# For example this will block all loaders except JPEG
|
825
|
+
#
|
826
|
+
# Vips.block("VipsForeignLoad", true);
|
827
|
+
# Vips.block("VipsForeignLoadJpeg", false)
|
828
|
+
#
|
829
|
+
# Use `vips -l` at the command-line to see the class hierarchy.
|
830
|
+
# This call does nothing if the named operation is not found.
|
831
|
+
#
|
832
|
+
def self.block(operation_name, state)
|
833
|
+
vips_operation_block_set(operation_name, state ? 1 : 0)
|
834
|
+
end
|
835
|
+
end
|
836
|
+
|
699
837
|
# Get a list of all supported file suffixes.
|
700
838
|
#
|
701
839
|
# @return [[String]] array of supported suffixes
|
data/ruby-vips.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.required_ruby_version = ">= 2.0.0"
|
37
37
|
|
38
38
|
spec.add_runtime_dependency "ffi", ["~> 1.12"]
|
39
|
+
spec.add_runtime_dependency "logger"
|
39
40
|
|
40
41
|
spec.add_development_dependency "rake", ["~> 12.0"]
|
41
42
|
spec.add_development_dependency "rspec", ["~> 3.3"]
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-vips
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Cupitt
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-06-05 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: ffi
|
@@ -24,6 +23,20 @@ dependencies:
|
|
24
23
|
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: '1.12'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: logger
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
27
40
|
- !ruby/object:Gem::Dependency
|
28
41
|
name: rake
|
29
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,6 +126,7 @@ extra_rdoc_files:
|
|
113
126
|
- TODO
|
114
127
|
files:
|
115
128
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
129
|
+
- ".github/dependabot.yml"
|
116
130
|
- ".github/workflows/test.yml"
|
117
131
|
- ".gitignore"
|
118
132
|
- ".standard.yml"
|
@@ -135,6 +149,7 @@ files:
|
|
135
149
|
- example/example5.rb
|
136
150
|
- example/inheritance_with_refcount.rb
|
137
151
|
- example/progress.rb
|
152
|
+
- example/revalidate.rb
|
138
153
|
- example/thumb.rb
|
139
154
|
- example/trim8.rb
|
140
155
|
- example/watermark.rb
|
@@ -189,7 +204,6 @@ metadata:
|
|
189
204
|
homepage_uri: http://github.com/libvips/ruby-vips
|
190
205
|
source_code_uri: https://github.com/libvips/ruby-vips
|
191
206
|
msys2_mingw_dependencies: libvips
|
192
|
-
post_install_message:
|
193
207
|
rdoc_options: []
|
194
208
|
require_paths:
|
195
209
|
- lib
|
@@ -204,8 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
218
|
- !ruby/object:Gem::Version
|
205
219
|
version: '0'
|
206
220
|
requirements: []
|
207
|
-
rubygems_version: 3.
|
208
|
-
signing_key:
|
221
|
+
rubygems_version: 3.6.3
|
209
222
|
specification_version: 4
|
210
223
|
summary: A fast image processing library with low memory needs
|
211
224
|
test_files: []
|