ruby-vips 2.1.4 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 pointer
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.
@@ -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 value
221
+ super(value)
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 name, value
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
- # collect a list of all input references here
444
- references = Set.new
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.each do |i|
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 += 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 << op.get(value)
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
- ptr = Vips.vips_region_new name
48
- raise Vips::Error if ptr.null?
47
+ pointer = Vips.vips_region_new name
48
+ raise Vips::Error if pointer.null?
49
49
 
50
- super ptr
50
+ super(pointer)
51
51
  end
52
52
 
53
53
  def width
@@ -47,7 +47,7 @@ module Vips
47
47
  pointer = Vips.vips_source_custom_new
48
48
  raise Vips::Error if pointer.null?
49
49
 
50
- super pointer
50
+ super(pointer)
51
51
  end
52
52
 
53
53
  # The block is executed to read data from the source. The interface is
@@ -47,7 +47,7 @@ module Vips
47
47
  pointer = Vips.vips_target_custom_new
48
48
  raise Vips::Error if pointer.null?
49
49
 
50
- super pointer
50
+ super(pointer)
51
51
  end
52
52
 
53
53
  # The block is executed to write data to the source. The interface is
data/lib/vips/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vips
2
- VERSION = "2.1.4"
2
+ VERSION = "2.2.1"
3
3
  end
data/lib/vips.rb CHANGED
@@ -625,7 +625,12 @@ module Vips
625
625
 
626
626
  attach_function :vips_leak_set, [:int], :void
627
627
  attach_function :vips_vector_set_enabled, [:int], :void
628
+ attach_function :vips_vector_isenabled, [], :int
628
629
  attach_function :vips_concurrency_set, [:int], :void
630
+ attach_function :vips_concurrency_get, [], :int
631
+
632
+ # Track the original default concurrency so we can reset to it.
633
+ DEFAULT_CONCURRENCY = vips_concurrency_get
629
634
 
630
635
  # vips_foreign_get_suffixes was added in libvips 8.8
631
636
  begin
@@ -640,20 +645,66 @@ module Vips
640
645
  vips_leak_set((leak ? 1 : 0))
641
646
  end
642
647
 
648
+ attach_function :vips_tracked_get_mem, [], :int
649
+ attach_function :vips_tracked_get_mem_highwater, [], :int
650
+ attach_function :vips_tracked_get_allocs, [], :int
651
+ attach_function :vips_tracked_get_files, [], :int
652
+ attach_function :vips_cache_get_max, [], :int
653
+ attach_function :vips_cache_get_max_mem, [], :int
654
+ attach_function :vips_cache_get_max_files, [], :int
643
655
  attach_function :vips_cache_set_max, [:int], :void
644
656
  attach_function :vips_cache_set_max_mem, [:int], :void
645
657
  attach_function :vips_cache_set_max_files, [:int], :void
658
+ attach_function :vips_cache_print, [], :void
659
+ attach_function :vips_cache_drop_all, [], :void
660
+
661
+ # Get the number of bytes currently allocated via vips_malloc.
662
+ def self.tracked_mem
663
+ vips_tracked_get_mem
664
+ end
665
+
666
+ # Get the greatest number of bytes ever actively allocated via vips_malloc.
667
+ def self.tracked_mem_highwater
668
+ vips_tracked_get_mem_highwater
669
+ end
670
+
671
+ # Get the number of active allocations.
672
+ def self.tracked_allocs
673
+ vips_tracked_get_allocs
674
+ end
675
+
676
+ # Get the number of open files.
677
+ def self.tracked_files
678
+ vips_tracked_get_files
679
+ end
680
+
681
+ # Get the maximum number of operations that libvips should cache.
682
+ def self.cache_max
683
+ vips_cache_get_max
684
+ end
685
+
686
+ # Get the maximum amount of memory that libvips uses for the operation cache.
687
+ def self.cache_max_mem
688
+ vips_cache_get_max_mem
689
+ end
690
+
691
+ # Get the maximum number of files libvips keeps open in the operation cache.
692
+ def self.cache_max_files
693
+ vips_cache_get_max_files
694
+ end
646
695
 
647
696
  # Set the maximum number of operations that libvips should cache. Set 0 to
648
697
  # disable the operation cache. The default is 1000.
649
698
  def self.cache_set_max size
650
699
  vips_cache_set_max size
700
+ cache_max
651
701
  end
652
702
 
653
703
  # Set the maximum amount of memory that libvips should use for the operation
654
704
  # cache. Set 0 to disable the operation cache. The default is 100mb.
655
705
  def self.cache_set_max_mem size
656
706
  vips_cache_set_max_mem size
707
+ cache_max_mem
657
708
  end
658
709
 
659
710
  # Set the maximum number of files libvips should keep open in the
@@ -661,12 +712,43 @@ module Vips
661
712
  # 100.
662
713
  def self.cache_set_max_files size
663
714
  vips_cache_set_max_files size
715
+ cache_max_files
716
+ end
717
+
718
+ # Print the libvips operation cache to stdout. Handy for debugging.
719
+ def self.cache_print # :nodoc:
720
+ vips_cache_print
721
+ end
722
+
723
+ # Drop the libvips operation cache. Handy for leak tracking.
724
+ def self.cache_drop_all # :nodoc:
725
+ vips_cache_drop_all
664
726
  end
665
727
 
666
- # Set the size of the libvips worker pool. This defaults to the number of
667
- # hardware threads on your computer. Set to 1 to disable threading.
728
+ # Get the size of libvips worker pools. Defaults to the VIPS_CONCURRENCY env
729
+ # var or the number of hardware threads on your computer.
730
+ def self.concurrency
731
+ vips_concurrency_get
732
+ end
733
+
734
+ # Get the default size of libvips worker pools.
735
+ def self.concurrency_default
736
+ DEFAULT_CONCURRENCY
737
+ end
738
+
739
+ # Set the size of each libvips worker pool. Max 1024 threads. Set to 1 to
740
+ # disable threading. Set to 0 or nil to reset to default.
668
741
  def self.concurrency_set n
742
+ n = DEFAULT_CONCURRENCY if n.to_i == 0
669
743
  vips_concurrency_set n
744
+ concurrency
745
+ end
746
+
747
+ # Whether SIMD and the run-time compiler are enabled. This can give a nice
748
+ # speed-up, but can also be unstable on some systems or with some versions
749
+ # of the run-time compiler.
750
+ def self.vector?
751
+ vips_vector_isenabled == 1
670
752
  end
671
753
 
672
754
  # Enable or disable SIMD and the run-time compiler. This can give a nice
@@ -674,6 +756,7 @@ module Vips
674
756
  # of the run-time compiler.
675
757
  def self.vector_set enabled
676
758
  vips_vector_set_enabled(enabled ? 1 : 0)
759
+ vector?
677
760
  end
678
761
 
679
762
  # Deprecated compatibility function.
@@ -696,6 +779,31 @@ module Vips
696
779
  major > x || (major == x && minor >= y)
697
780
  end
698
781
 
782
+ if at_least_libvips?(8, 13)
783
+ attach_function :vips_block_untrusted_set, [:bool], :void
784
+ attach_function :vips_operation_block_set, %i[string bool], :void
785
+
786
+ # Block/unblock all untrusted operations from running.
787
+ # Use `vips -l` at the command-line to see the class hierarchy and which operations are marked as untrusted.
788
+ def self.block_untrusted(enabled)
789
+ vips_block_untrusted_set(enabled)
790
+ end
791
+
792
+ # Block/unblock all operations in the libvips class hierarchy at specified *operation_name* and below.
793
+ #
794
+ # For example this will block all loaders except JPEG
795
+ #
796
+ # Vips.block("VipsForeignLoad", true);
797
+ # Vips.block("VipsForeignLoadJpeg", false)
798
+ #
799
+ # Use `vips -l` at the command-line to see the class hierarchy.
800
+ # This call does nothing if the named operation is not found.
801
+ #
802
+ def self.block(operation_name, enabled)
803
+ vips_operation_block_set(operation_name, enabled)
804
+ end
805
+ end
806
+
699
807
  # Get a list of all supported file suffixes.
700
808
  #
701
809
  # @return [[String]] array of supported suffixes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-vips
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Cupitt
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-20 00:00:00.000000000 Z
11
+ date: 2024-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -113,6 +113,7 @@ extra_rdoc_files:
113
113
  - TODO
114
114
  files:
115
115
  - ".github/ISSUE_TEMPLATE/bug_report.md"
116
+ - ".github/dependabot.yml"
116
117
  - ".github/workflows/test.yml"
117
118
  - ".gitignore"
118
119
  - ".standard.yml"
@@ -135,6 +136,7 @@ files:
135
136
  - example/example5.rb
136
137
  - example/inheritance_with_refcount.rb
137
138
  - example/progress.rb
139
+ - example/revalidate.rb
138
140
  - example/thumb.rb
139
141
  - example/trim8.rb
140
142
  - example/watermark.rb
@@ -189,7 +191,7 @@ metadata:
189
191
  homepage_uri: http://github.com/libvips/ruby-vips
190
192
  source_code_uri: https://github.com/libvips/ruby-vips
191
193
  msys2_mingw_dependencies: libvips
192
- post_install_message:
194
+ post_install_message:
193
195
  rdoc_options: []
194
196
  require_paths:
195
197
  - lib
@@ -204,8 +206,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
206
  - !ruby/object:Gem::Version
205
207
  version: '0'
206
208
  requirements: []
207
- rubygems_version: 3.2.5
208
- signing_key:
209
+ rubygems_version: 3.3.15
210
+ signing_key:
209
211
  specification_version: 4
210
212
  summary: A fast image processing library with low memory needs
211
213
  test_files: []