diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ace460 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 64a8668..a7216f4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,13 +1,6 @@ name: Test -on: - push: - branches: - - master - pull_request: - pull_request_target: - branches: - - master +on: [push, pull_request] env: NOKOGIRI_USE_SYSTEM_LIBRARIES: true @@ -20,7 +13,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -36,17 +29,17 @@ jobs: strategy: matrix: - os-version: [ 'ubuntu-20.04' ] + os-version: [ 'ubuntu-24.04' ] ruby-version: - - 2.0 - - 2.1 - - 2.2 - - 2.3 - - 2.4 - - 2.5 - - 2.6 - - 2.7 - - 3.0 + - '2.3' + - '2.4' + - '2.5' + - '2.6' + - '2.7' + - '3.0' + - '3.1' + - '3.2' + - '3.3' - jruby fail-fast: true @@ -54,7 +47,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -62,19 +55,11 @@ jobs: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true - - name: Update apt - env: - DEBIAN_FRONTEND: noninteractive - run: - sudo apt-get update -qq -o Acquire::Retries=3 - - name: Install libvips - env: - DEBIAN_FRONTEND: noninteractive - run: + run: | + sudo apt-get update # we only need the library - sudo apt-get install --fix-missing -qq -o Acquire::Retries=3 - libvips + sudo apt-get install --no-install-recommends libvips - name: Run Tests run: bundle exec rake spec diff --git a/CHANGELOG.md b/CHANGELOG.md index b494706..876f8fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,40 @@ ## master +## Version 2.2.3 (2025-02-06) + +* fix `Image#add_alpha()` with libvips 8.16 [kleisauke] +* fix FFI function definitions for `gboolean` parameters [kleisauke] + +## Version 2.2.2 (2024-07-17) + +* fix compat with unified (semistatic) libvips binaries [kleisauke] + +## Version 2.2.1 (2024-02-21) + +* add `Vips.block_untrusted` method to block all untrusted operations. Only for libvips >= 8.13. [Docs](https://www.libvips.org/API/current/libvips-vips.html#vips-block-untrusted-set). [#382](https://github.com/libvips/ruby-vips/pull/382) [aglushkov](https://github.com/aglushkov) +* add `Vips.block` method to block specific operation. Only for libvips >= 8.13. [Docs](https://www.libvips.org/API/current/VipsOperation.html#vips-operation-block-set). [#382](https://github.com/libvips/ruby-vips/pull/382) [aglushkov](https://github.com/aglushkov) +* `new_from_source` keeps a ref to the source object [taylorthurlow] +* some fixes to object references system + +## Version 2.2.0 (2023-10-18) + +* add `draw_point!` [jcupitt] +* add `Vips.tracked_*` for getting file and memory metrics [jeremy] +* add `Vips.cache_*` for getting cache settings [jeremy] +* add `Vips.vector?` to get/set SIMD status [jeremy] +* add `Vips.concurrency` to get/set threadpool size [jeremy] +* add `Vips.concurrency_default` to get the default threadpool size [jeremy] +* fix targetcustom spec test with libvips 8.13 [lucaskanashiro] +* add ruby 3.2 to CI [petergoldstein] +* update docs for libvips 8.15 [jcupitt] + ## Version 2.1.4 (2021-10-28) * `write_to_buffer` tries to use the new target API, then falls back to the old buffer system [jcupitt] * don't generate yard docs for deprecated args [jcupitt] +* add hyperbolic trig functions [jcupitt] ## Version 2.1.3 (2021-8-23) diff --git a/README.md b/README.md index c1eeaff..068a953 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,10 @@ [![Test](https://github.com/libvips/ruby-vips/workflows/Test/badge.svg)](https://github.com/libvips/ruby-vips/actions?query=workflow%3ATest) This gem is a Ruby binding for the [libvips image processing -library](https://libvips.github.io/libvips). +library](https://libvips.github.io/libvips). It has been tested on +Linux, macOS and Windows, and with ruby 2, ruby 3 and jruby. It uses +[ruby-ffi](https://github.com/ffi/ffi) to call functions in the libvips +library. libvips is a [demand-driven, horizontally threaded](https://github.com/libvips/libvips/wiki/Why-is-libvips-quick) @@ -14,32 +17,30 @@ memory](https://github.com/libvips/libvips/wiki/Speed-and-memory-use). libvips is licensed under the [LGPL 2.1+](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html). -## Requirements +## Install on linux and macOS - * macOS, Linux, and Windows tested +Install the libvips binary with your package manager (eg. `apt install +libvips42` or perhaps `brew install vips`, see the [libvips install +instructions](https://libvips.github.io/libvips/install.html)) then install +this gem with: - * libvips 8.2 or later, see the [libvips install instructions](https://libvips.github.io/libvips/install.html) - - * [ruby-ffi](https://github.com/ffi/ffi) 1.9 or later +``` +gem install ruby-vips +``` - * Ruby 2.0+, JRuby +Or include `gem "ruby-vips"` in your gemfile. -## Install +## Install on Windows -[Install libvips](https://libvips.github.io/libvips/install.html), then: +The gemspec will pull in the msys libvips for you, so all you need is: ``` -$ gem install ruby-vips +gem install ruby-vips ``` -or include it in `Gemfile`: +Or include `gem "ruby-vips"` in your gemfile. -```ruby -gem "ruby-vips" -``` - -On Windows, you'll need to set the `RUBY_DLL_PATH` environment variable to -point to the libvips bin directory. +Tested with the ruby and msys from choco, but others may work. ## Example @@ -106,4 +107,3 @@ rmagick.rb 788768 See also [benchmarks at the official libvips website](https://github.com/libvips/libvips/wiki/Speed-and-memory-use). - diff --git a/TODO b/TODO index 5f19a37..1e44966 100644 --- a/TODO +++ b/TODO @@ -37,8 +37,7 @@ - Push new gem to rubygems, tag repository with version. - gem signin --otp 111111 bundle exec rake release - The otp is from authy / google authenticator / etc. + You'll be asked for a otp from authy / google authenticator / etc. diff --git a/VERSION b/VERSION index 7d2ed7c..5859406 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1.4 +2.2.3 diff --git a/example/revalidate.rb b/example/revalidate.rb new file mode 100755 index 0000000..31e00a4 --- /dev/null +++ b/example/revalidate.rb @@ -0,0 +1,39 @@ +#!/usr/bin/ruby + +# demo the "revalidate" feature in libvips 8.15 + +require "fileutils" +require "vips" + +if ARGV.length != 2 + puts "usage: ./revalidate.rb IMAGE-FILE-1 IMAGE-FILE-2" + exit 1 +end + +if File.exist?("fred") + puts "file 'fred' exists, delete it first" + exit 1 +end + +puts "copying #{ARGV[0]} to fred ..." +FileUtils.cp(ARGV[0], "fred") + +image1 = Vips::Image.new_from_file("fred") +puts "fred.width = #{image1.width}" + +puts "copying #{ARGV[1]} to fred ..." +FileUtils.cp(ARGV[1], "fred") + +puts "plain image open ..." +image2 = Vips::Image.new_from_file("fred") +puts "fred.width = #{image2.width}" + +puts "opening with revalidate ..." +image2 = Vips::Image.new_from_file("fred", revalidate: true) +puts "fred.width = #{image2.width}" + +puts "opening again, should get cached entry ..." +image2 = Vips::Image.new_from_file("fred") +puts "fred.width = #{image2.width}" + +File.delete("fred") diff --git a/lib/vips.rb b/lib/vips.rb index 1edd735..aed3f1a 100644 --- a/lib/vips.rb +++ b/lib/vips.rb @@ -33,6 +33,30 @@ def library_name(name, abi_number) end end +# we can sometimes get dependent libraries from libvips -- either the platform +# will open dependencies for us automatically, or the libvips binary has been +# built to includes all main dependencies (common on windows, can happen +# elsewhere) +# +# we must get glib functions from libvips if we can, since it will be the +# one that libvips itself is using, and they will share runtime types +module Vips + extend FFI::Library + + ffi_lib library_name("vips", 42) + + begin + attach_function :g_malloc, [:size_t], :pointer + @@is_unified = true + rescue FFI::NotFoundError + @@is_unified = false + end + + def self.unified? + @@is_unified + end +end + module GLib class << self attr_accessor :logger @@ -42,7 +66,11 @@ class << self extend FFI::Library - ffi_lib library_name("glib-2.0", 0) + if Vips.unified? + ffi_lib library_name("vips", 42) + else + ffi_lib library_name("glib-2.0", 0) + end attach_function :g_malloc, [:size_t], :pointer @@ -134,7 +162,11 @@ def self.set_log_domain domain module GObject extend FFI::Library - ffi_lib library_name("gobject-2.0", 0) + if Vips.unified? + ffi_lib library_name("vips", 42) + else + ffi_lib library_name("gobject-2.0", 0) + end # we can't just use ulong, windows has different int sizing rules if FFI::Platform::ADDRESS_SIZE == 64 @@ -568,9 +600,7 @@ module GObject # {Image#median}. module Vips - extend FFI::Library - - ffi_lib library_name("vips", 42) + # we've already opened the libvips library LOG_DOMAIN = "VIPS" GLib.set_log_domain LOG_DOMAIN @@ -625,7 +655,12 @@ def to_s attach_function :vips_leak_set, [:int], :void attach_function :vips_vector_set_enabled, [:int], :void + attach_function :vips_vector_isenabled, [], :int attach_function :vips_concurrency_set, [:int], :void + attach_function :vips_concurrency_get, [], :int + + # Track the original default concurrency so we can reset to it. + DEFAULT_CONCURRENCY = vips_concurrency_get # vips_foreign_get_suffixes was added in libvips 8.8 begin @@ -640,20 +675,66 @@ def self.leak_set leak vips_leak_set((leak ? 1 : 0)) end + attach_function :vips_tracked_get_mem, [], :int + attach_function :vips_tracked_get_mem_highwater, [], :int + attach_function :vips_tracked_get_allocs, [], :int + attach_function :vips_tracked_get_files, [], :int + attach_function :vips_cache_get_max, [], :int + attach_function :vips_cache_get_max_mem, [], :int + attach_function :vips_cache_get_max_files, [], :int attach_function :vips_cache_set_max, [:int], :void attach_function :vips_cache_set_max_mem, [:int], :void attach_function :vips_cache_set_max_files, [:int], :void + attach_function :vips_cache_print, [], :void + attach_function :vips_cache_drop_all, [], :void + + # Get the number of bytes currently allocated via vips_malloc. + def self.tracked_mem + vips_tracked_get_mem + end + + # Get the greatest number of bytes ever actively allocated via vips_malloc. + def self.tracked_mem_highwater + vips_tracked_get_mem_highwater + end + + # Get the number of active allocations. + def self.tracked_allocs + vips_tracked_get_allocs + end + + # Get the number of open files. + def self.tracked_files + vips_tracked_get_files + end + + # Get the maximum number of operations that libvips should cache. + def self.cache_max + vips_cache_get_max + end + + # Get the maximum amount of memory that libvips uses for the operation cache. + def self.cache_max_mem + vips_cache_get_max_mem + end + + # Get the maximum number of files libvips keeps open in the operation cache. + def self.cache_max_files + vips_cache_get_max_files + end # Set the maximum number of operations that libvips should cache. Set 0 to # disable the operation cache. The default is 1000. def self.cache_set_max size vips_cache_set_max size + cache_max end # Set the maximum amount of memory that libvips should use for the operation # cache. Set 0 to disable the operation cache. The default is 100mb. def self.cache_set_max_mem size vips_cache_set_max_mem size + cache_max_mem end # Set the maximum number of files libvips should keep open in the @@ -661,12 +742,43 @@ def self.cache_set_max_mem size # 100. def self.cache_set_max_files size vips_cache_set_max_files size + cache_max_files + end + + # Print the libvips operation cache to stdout. Handy for debugging. + def self.cache_print # :nodoc: + vips_cache_print + end + + # Drop the libvips operation cache. Handy for leak tracking. + def self.cache_drop_all # :nodoc: + vips_cache_drop_all + end + + # Get the size of libvips worker pools. Defaults to the VIPS_CONCURRENCY env + # var or the number of hardware threads on your computer. + def self.concurrency + vips_concurrency_get + end + + # Get the default size of libvips worker pools. + def self.concurrency_default + DEFAULT_CONCURRENCY end - # Set the size of the libvips worker pool. This defaults to the number of - # hardware threads on your computer. Set to 1 to disable threading. + # Set the size of each libvips worker pool. Max 1024 threads. Set to 1 to + # disable threading. Set to 0 or nil to reset to default. def self.concurrency_set n + n = DEFAULT_CONCURRENCY if n.to_i == 0 vips_concurrency_set n + concurrency + end + + # Whether SIMD and the run-time compiler are enabled. This can give a nice + # speed-up, but can also be unstable on some systems or with some versions + # of the run-time compiler. + def self.vector? + vips_vector_isenabled == 1 end # Enable or disable SIMD and the run-time compiler. This can give a nice @@ -674,6 +786,7 @@ def self.concurrency_set n # of the run-time compiler. def self.vector_set enabled vips_vector_set_enabled(enabled ? 1 : 0) + vector? end # Deprecated compatibility function. @@ -696,6 +809,31 @@ def self.at_least_libvips?(x, y) major > x || (major == x && minor >= y) end + if at_least_libvips?(8, 13) + attach_function :vips_block_untrusted_set, [:int], :void + attach_function :vips_operation_block_set, [:string, :int], :void + + # Block/unblock all untrusted operations from running. + # Use `vips -l` at the command-line to see the class hierarchy and which operations are marked as untrusted. + def self.block_untrusted(state) + vips_block_untrusted_set(state ? 1 : 0) + end + + # Block/unblock all operations in the libvips class hierarchy at specified *operation_name* and below. + # + # For example this will block all loaders except JPEG + # + # Vips.block("VipsForeignLoad", true); + # Vips.block("VipsForeignLoadJpeg", false) + # + # Use `vips -l` at the command-line to see the class hierarchy. + # This call does nothing if the named operation is not found. + # + def self.block(operation_name, state) + vips_operation_block_set(operation_name, state ? 1 : 0) + end + end + # Get a list of all supported file suffixes. # # @return [[String]] array of supported suffixes diff --git a/lib/vips/image.rb b/lib/vips/image.rb index 823e7ff..ea8b1af 100644 --- a/lib/vips/image.rb +++ b/lib/vips/image.rb @@ -14,8 +14,8 @@ module Vips attach_function :vips_image_copy_memory, [:pointer], :pointer - attach_function :vips_image_set_progress, [:pointer, :bool], :void - attach_function :vips_image_set_kill, [:pointer, :bool], :void + attach_function :vips_image_set_progress, [:pointer, :int], :void + attach_function :vips_image_set_kill, [:pointer, :int], :void attach_function :vips_filename_get_filename, [:string], :pointer attach_function :vips_filename_get_options, [:string], :pointer @@ -138,14 +138,14 @@ def self.run_cmplx image, &block image = image.cast :float end - new_format = image.format == :double ? :dpcomplex : :complex + new_format = (image.format == :double) ? :dpcomplex : :complex image = image.copy format: new_format, bands: image.bands / 2 end image = block.call(image) unless Image.complex? original_format - new_format = image.format == :dpcomplex ? :double : :float + new_format = (image.format == :dpcomplex) ? :double : :float image = image.copy format: new_format, bands: image.bands * 2 end @@ -458,7 +458,14 @@ def self.new_from_source source, option_string, **opts loader = Vips.vips_foreign_find_load_source source raise Vips::Error if loader.nil? - Vips::Operation.call loader, [source], opts, option_string + result = Vips::Operation.call loader, [source], opts, option_string + + # keep a secret ref to the source object ... the libvips loader will + # keep a ref to the C source object, but we need the ruby wrapper object + # to stay alive too + result.references << source + + result end def self.matrix_from_array width, height, array @@ -634,7 +641,7 @@ def write_to_buffer format_string, **opts end if !saver.nil? - target = Vips::Target::new_to_memory + target = Vips::Target.new_to_memory Vips::Operation.call saver, [self, target], opts, option_string buffer = target.get("blob") else @@ -709,7 +716,7 @@ def write_to_memory # @see Object#signal_connect # @param state [Boolean] progress signalling state def set_progress state - Vips.vips_image_set_progress self, state + Vips.vips_image_set_progress(self, state ? 1 : 0) end # Kill computation of this time. @@ -720,7 +727,7 @@ def set_progress state # @see Object#signal_connect # @param kill [Boolean] stop computation def set_kill kill - Vips.vips_image_set_kill self, kill + Vips.vips_image_set_kill(self, kill ? 1 : 0) end # Get the `GType` of a metadata field. The result is 0 if no such field @@ -966,7 +973,7 @@ def has_alpha? # @return [Image] new image def add_alpha ptr = GenericPtr.new - result = Vips.vips_addalpha self, ptr + result = Vips.vips_addalpha self, ptr, :pointer, nil raise Vips::Error if result != 0 Vips::Image.new ptr[:value] @@ -1450,6 +1457,48 @@ def atan math :atan end + # Return the hyperbolic sine of an image in radians. + # + # @return [Image] sine of each pixel + def sinh + math :sinh + end + + # Return the hyperbolic cosine of an image in radians. + # + # @return [Image] cosine of each pixel + def cosh + math :cosh + end + + # Return the hyperbolic tangent of an image in radians. + # + # @return [Image] tangent of each pixel + def tanh + math :tanh + end + + # Return the inverse hyperbolic sine of an image in radians. + # + # @return [Image] inverse sine of each pixel + def asinh + math :asinh + end + + # Return the inverse hyperbolic cosine of an image in radians. + # + # @return [Image] inverse cosine of each pixel + def acosh + math :acosh + end + + # Return the inverse hyperbolic tangent of an image in radians. + # + # @return [Image] inverse tangent of each pixel + def atanh + math :atanh + end + # Return the natural log of an image. # # @return [Image] natural log of each pixel @@ -1632,8 +1681,8 @@ def self.generate_operation introspect method_args = introspect.method_args required_output = introspect.required_output - optional_input = introspect.optional_input - optional_output = introspect.optional_output + optional_input = introspect.doc_optional_input + optional_output = introspect.doc_optional_output print "# @!method " print "self." unless introspect.member_x @@ -1654,8 +1703,6 @@ def self.generate_operation introspect puts "# @param opts [Hash] Set of options" optional_input.each do |arg_name, details| - next if (details[:flags] & ARGUMENT_DEPRECATED) != 0 - yard_name = details[:yard_name] gtype = details[:gtype] rtype = gtype_to_ruby gtype @@ -1664,8 +1711,6 @@ def self.generate_operation introspect puts "# @option opts [#{rtype}] :#{yard_name} #{blurb}" end optional_output.each do |arg_name, details| - next if (details[:flags] & ARGUMENT_DEPRECATED) != 0 - yard_name = details[:yard_name] gtype = details[:gtype] rtype = gtype_to_ruby gtype diff --git a/lib/vips/interpolate.rb b/lib/vips/interpolate.rb index 7897a5e..e31450a 100644 --- a/lib/vips/interpolate.rb +++ b/lib/vips/interpolate.rb @@ -49,10 +49,10 @@ class ManagedStruct < Vips::Object::ManagedStruct def initialize name name = name.to_s if name.is_a? Symbol - ptr = Vips.vips_interpolate_new name - raise Vips::Error if ptr.nil? + pointer = Vips.vips_interpolate_new name + raise Vips::Error if pointer.nil? - super ptr + super(pointer) end end end diff --git a/lib/vips/methods.rb b/lib/vips/methods.rb index 3b4963f..a514d71 100644 --- a/lib/vips/methods.rb +++ b/lib/vips/methods.rb @@ -18,6 +18,18 @@ class Image # @param opts [Hash] Set of options # @return [Vips::Image] Output image +# @!method minpair(right, **opts) +# Minimum of a pair of images. +# @param right [Vips::Image] Right-hand image argument +# @param opts [Hash] Set of options +# @return [Vips::Image] Output image + +# @!method maxpair(right, **opts) +# Maximum of a pair of images. +# @param right [Vips::Image] Right-hand image argument +# @param opts [Hash] Set of options +# @return [Vips::Image] Output image + # @!method subtract(right, **opts) # Subtract two images. # @param right [Vips::Image] Right-hand image argument @@ -39,7 +51,7 @@ class Image # @!method relational(right, relational, **opts) # Relational operation on two images. # @param right [Vips::Image] Right-hand image argument -# @param relational [Vips::OperationRelational] relational to perform +# @param relational [Vips::OperationRelational] Relational to perform # @param opts [Hash] Set of options # @return [Vips::Image] Output image @@ -52,21 +64,21 @@ class Image # @!method boolean(right, boolean, **opts) # Boolean operation on two images. # @param right [Vips::Image] Right-hand image argument -# @param boolean [Vips::OperationBoolean] boolean to perform +# @param boolean [Vips::OperationBoolean] Boolean to perform # @param opts [Hash] Set of options # @return [Vips::Image] Output image # @!method math2(right, math2, **opts) # Binary math operations. # @param right [Vips::Image] Right-hand image argument -# @param math2 [Vips::OperationMath2] math to perform +# @param math2 [Vips::OperationMath2] Math to perform # @param opts [Hash] Set of options # @return [Vips::Image] Output image # @!method complex2(right, cmplx, **opts) # Complex binary operations on two images. # @param right [Vips::Image] Right-hand image argument -# @param cmplx [Vips::OperationComplex2] binary complex operation to perform +# @param cmplx [Vips::OperationComplex2] Binary complex operation to perform # @param opts [Hash] Set of options # @return [Vips::Image] Output image @@ -76,10 +88,11 @@ class Image # @param opts [Hash] Set of options # @return [Vips::Image] Output image -# @!method self.sum(im, **opts) -# Sum an array of images. -# @param im [Array] Array of input images +# @!method clamp(**opts) +# Clamp values of an image. # @param opts [Hash] Set of options +# @option opts [Float] :min Minimum value +# @option opts [Float] :max Maximum value # @return [Vips::Image] Output image # @!method invert(**opts) @@ -97,7 +110,7 @@ class Image # @!method math(math, **opts) # Apply a math operation to an image. -# @param math [Vips::OperationMath] math to perform +# @param math [Vips::OperationMath] Math to perform # @param opts [Hash] Set of options # @return [Vips::Image] Output image @@ -113,13 +126,13 @@ class Image # @!method round(round, **opts) # Perform a round function on an image. -# @param round [Vips::OperationRound] rounding operation to perform +# @param round [Vips::OperationRound] Rounding operation to perform # @param opts [Hash] Set of options # @return [Vips::Image] Output image # @!method relational_const(relational, c, **opts) # Relational operations against a constant. -# @param relational [Vips::OperationRelational] relational to perform +# @param relational [Vips::OperationRelational] Relational to perform # @param c [Array] Array of constants # @param opts [Hash] Set of options # @return [Vips::Image] Output image @@ -132,27 +145,33 @@ class Image # @!method boolean_const(boolean, c, **opts) # Boolean operations against a constant. -# @param boolean [Vips::OperationBoolean] boolean to perform +# @param boolean [Vips::OperationBoolean] Boolean to perform # @param c [Array] Array of constants # @param opts [Hash] Set of options # @return [Vips::Image] Output image # @!method math2_const(math2, c, **opts) # Binary math operations with a constant. -# @param math2 [Vips::OperationMath2] math to perform +# @param math2 [Vips::OperationMath2] Math to perform # @param c [Array] Array of constants # @param opts [Hash] Set of options # @return [Vips::Image] Output image # @!method complex(cmplx, **opts) # Perform a complex operation on an image. -# @param cmplx [Vips::OperationComplex] complex to perform +# @param cmplx [Vips::OperationComplex] Complex to perform # @param opts [Hash] Set of options # @return [Vips::Image] Output image # @!method complexget(get, **opts) # Get a component from a complex image. -# @param get [Vips::OperationComplexget] complex to perform +# @param get [Vips::OperationComplexget] Complex to perform +# @param opts [Hash] Set of options +# @return [Vips::Image] Output image + +# @!method self.sum(im, **opts) +# Sum an array of images. +# @param im [Array] Array of input images # @param opts [Hash] Set of options # @return [Vips::Image] Output image @@ -215,7 +234,7 @@ class Image # @!method hough_line(**opts) # Find hough line transform. # @param opts [Hash] Set of options -# @option opts [Integer] :width horizontal size of parameter space +# @option opts [Integer] :width Horizontal size of parameter space # @option opts [Integer] :height Vertical size of parameter space # @return [Vips::Image] Output image @@ -253,6 +272,7 @@ class Image # @param x [Integer] Point to read # @param y [Integer] Point to read # @param opts [Hash] Set of options +# @option opts [Boolean] :unpack_complex Complex pixels should be unpacked # @return [Array] Array of output values # @!method find_trim(**opts) @@ -260,6 +280,7 @@ class Image # @param opts [Hash] Set of options # @option opts [Float] :threshold Object threshold # @option opts [Array] :background Color for background pixels +# @option opts [Boolean] :line_art Enable line art mode # @return [Array] Left edge of image, Top edge of extract area, Width of extract area, Height of extract area # @!method copy(**opts) @@ -303,14 +324,6 @@ class Image # @option opts [Integer] :tile_height Tile height in pixels # @return [Vips::Image] Output image -# @!method cache(**opts) -# Cache an image. -# @param opts [Hash] Set of options -# @option opts [Integer] :max_tiles Maximum number of tiles to cache -# @option opts [Integer] :tile_height Tile height in pixels -# @option opts [Integer] :tile_width Tile width in pixels -# @return [Vips::Image] Output image - # @!method embed(x, y, width, height, **opts) # Embed an image in a larger image. # @param x [Integer] Left edge of input in output @@ -324,7 +337,7 @@ class Image # @!method gravity(direction, width, height, **opts) # Place an image within a larger image with a certain gravity. -# @param direction [Vips::CompassDirection] direction to place image within width/height +# @param direction [Vips::CompassDirection] Direction to place image within width/height # @param width [Integer] Image width in pixels # @param height [Integer] Image height in pixels # @param opts [Hash] Set of options @@ -396,7 +409,10 @@ class Image # @param height [Integer] Height of extract area # @param opts [Hash] Set of options # @option opts [Vips::Interesting] :interesting How to measure interestingness -# @return [Vips::Image] Output image +# @option opts [Boolean] :premultiplied Input image already has premultiplied alpha +# @option opts [Integer] :attention_x Output Horizontal position of attention centre +# @option opts [Integer] :attention_y Output Vertical position of attention centre +# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items # @!method extract_band(band, **opts) # Extract band from an image. @@ -425,7 +441,7 @@ class Image # @!method bandbool(boolean, **opts) # Boolean operation across image bands. -# @param boolean [Vips::OperationBoolean] boolean to perform +# @param boolean [Vips::OperationBoolean] Boolean to perform # @param opts [Hash] Set of options # @return [Vips::Image] Output image @@ -464,7 +480,7 @@ class Image # @!method recomb(m, **opts) # Linear recombination with matrix. -# @param m [Vips::Image] matrix of coefficients +# @param m [Vips::Image] Matrix of coefficients # @param opts [Hash] Set of options # @return [Vips::Image] Output image @@ -502,9 +518,9 @@ class Image # @!method grid(tile_height, across, down, **opts) # Grid an image. -# @param tile_height [Integer] chop into tiles this high -# @param across [Integer] number of tiles across -# @param down [Integer] number of tiles down +# @param tile_height [Integer] Chop into tiles this high +# @param across [Integer] Number of tiles across +# @param down [Integer] Number of tiles down # @param opts [Hash] Set of options # @return [Vips::Image] Output image @@ -569,6 +585,11 @@ class Image # @option opts [Boolean] :premultiplied Images have premultiplied alpha # @return [Vips::Image] Output image +# @!method addalpha(**opts) +# Append an alpha channel. +# @param opts [Hash] Set of options +# @return [Vips::Image] Output image + # @!method self.black(width, height, **opts) # Make a black image. # @param width [Integer] Image width in pixels @@ -608,10 +629,10 @@ class Image # @!method self.logmat(sigma, min_ampl, **opts) # Make a laplacian of gaussian image. -# @param sigma [Float] Radius of Logmatian -# @param min_ampl [Float] Minimum amplitude of Logmatian +# @param sigma [Float] Radius of Gaussian +# @param min_ampl [Float] Minimum amplitude of Gaussian # @param opts [Hash] Set of options -# @option opts [Boolean] :separable Generate separable Logmatian +# @option opts [Boolean] :separable Generate separable Gaussian # @option opts [Vips::Precision] :precision Generate with this precision # @return [Vips::Image] Output image @@ -623,14 +644,27 @@ class Image # @option opts [Integer] :width Maximum image width in pixels # @option opts [Integer] :height Maximum image height in pixels # @option opts [Vips::Align] :align Align on the low, centre or high edge -# @option opts [Boolean] :rgba Enable RGBA output -# @option opts [Integer] :dpi DPI to render at # @option opts [Boolean] :justify Justify lines +# @option opts [Integer] :dpi DPI to render at # @option opts [Integer] :spacing Line spacing # @option opts [String] :fontfile Load this font file +# @option opts [Boolean] :rgba Enable RGBA output +# @option opts [Vips::TextWrap] :wrap Wrap lines on word or character boundaries # @option opts [Integer] :autofit_dpi Output DPI selected by autofit # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items +# @!method self.sdf(width, height, shape, **opts) +# Create an sdf image. +# @param width [Integer] Image width in pixels +# @param height [Integer] Image height in pixels +# @param shape [Vips::SdfShape] SDF shape to create +# @param opts [Hash] Set of options +# @option opts [Float] :r Radius +# @option opts [Array] :a Point a +# @option opts [Array] :b Point b +# @option opts [Array] :corners Corner radii +# @return [Vips::Image] Output image + # @!method self.eye(width, height, **opts) # Make an image showing the eye's spatial response. # @param width [Integer] Image width in pixels @@ -697,7 +731,7 @@ class Image # @param height [Integer] Image height in pixels # @param frequency_cutoff_x [Float] Frequency cutoff x # @param frequency_cutoff_y [Float] Frequency cutoff y -# @param radius [Float] radius of circle +# @param radius [Float] Radius of circle # @param opts [Hash] Set of options # @option opts [Boolean] :uchar Output an unsigned char image # @option opts [Boolean] :nodc Remove DC component @@ -741,7 +775,7 @@ class Image # @param order [Float] Filter order # @param frequency_cutoff_x [Float] Frequency cutoff x # @param frequency_cutoff_y [Float] Frequency cutoff y -# @param radius [Float] radius of circle +# @param radius [Float] Radius of circle # @param amplitude_cutoff [Float] Amplitude cutoff # @param opts [Hash] Set of options # @option opts [Boolean] :uchar Output an unsigned char image @@ -783,7 +817,7 @@ class Image # @param height [Integer] Image height in pixels # @param frequency_cutoff_x [Float] Frequency cutoff x # @param frequency_cutoff_y [Float] Frequency cutoff y -# @param radius [Float] radius of circle +# @param radius [Float] Radius of circle # @param amplitude_cutoff [Float] Amplitude cutoff # @param opts [Hash] Set of options # @option opts [Boolean] :uchar Output an unsigned char image @@ -882,6 +916,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -896,6 +931,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -906,6 +942,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -916,6 +953,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -932,6 +970,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -942,6 +981,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -952,6 +992,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -962,6 +1003,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -972,6 +1014,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -982,6 +1025,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -992,6 +1036,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1002,6 +1047,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1012,51 +1058,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on -# @option opts [Vips::ForeignFlags] :flags Output Flags for this file -# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items - -# @!method self.pdfload(filename, **opts) -# Load pdf from file. -# @param filename [String] Filename to load from -# @param opts [Hash] Set of options -# @option opts [Integer] :page Load this page from the file -# @option opts [Integer] :n Load this many pages -# @option opts [Float] :dpi Render at this DPI -# @option opts [Float] :scale Scale output by this factor -# @option opts [Array] :background Background value -# @option opts [Boolean] :memory Force open via memory -# @option opts [Vips::Access] :access Required access pattern for this file -# @option opts [Vips::FailOn] :fail_on Error level to fail on -# @option opts [Vips::ForeignFlags] :flags Output Flags for this file -# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items - -# @!method self.pdfload_buffer(buffer, **opts) -# Load pdf from buffer. -# @param buffer [VipsBlob] Buffer to load from -# @param opts [Hash] Set of options -# @option opts [Integer] :page Load this page from the file -# @option opts [Integer] :n Load this many pages -# @option opts [Float] :dpi Render at this DPI -# @option opts [Float] :scale Scale output by this factor -# @option opts [Array] :background Background value -# @option opts [Boolean] :memory Force open via memory -# @option opts [Vips::Access] :access Required access pattern for this file -# @option opts [Vips::FailOn] :fail_on Error level to fail on -# @option opts [Vips::ForeignFlags] :flags Output Flags for this file -# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items - -# @!method self.pdfload_source(source, **opts) -# Load pdf from source. -# @param source [Vips::Source] Source to load from -# @param opts [Hash] Set of options -# @option opts [Integer] :page Load this page from the file -# @option opts [Integer] :n Load this many pages -# @option opts [Float] :dpi Render at this DPI -# @option opts [Float] :scale Scale output by this factor -# @option opts [Array] :background Background value -# @option opts [Boolean] :memory Force open via memory -# @option opts [Vips::Access] :access Required access pattern for this file -# @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1070,6 +1072,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1083,6 +1086,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1096,36 +1100,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on -# @option opts [Vips::ForeignFlags] :flags Output Flags for this file -# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items - -# @!method self.jxlload(filename, **opts) -# Load jpeg-xl image. -# @param filename [String] Filename to load from -# @param opts [Hash] Set of options -# @option opts [Boolean] :memory Force open via memory -# @option opts [Vips::Access] :access Required access pattern for this file -# @option opts [Vips::FailOn] :fail_on Error level to fail on -# @option opts [Vips::ForeignFlags] :flags Output Flags for this file -# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items - -# @!method self.jxlload_buffer(buffer, **opts) -# Load jpeg-xl image. -# @param buffer [VipsBlob] Buffer to load from -# @param opts [Hash] Set of options -# @option opts [Boolean] :memory Force open via memory -# @option opts [Vips::Access] :access Required access pattern for this file -# @option opts [Vips::FailOn] :fail_on Error level to fail on -# @option opts [Vips::ForeignFlags] :flags Output Flags for this file -# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items - -# @!method self.jxlload_source(source, **opts) -# Load jpeg-xl image. -# @param source [Vips::Source] Source to load from -# @param opts [Hash] Set of options -# @option opts [Boolean] :memory Force open via memory -# @option opts [Vips::Access] :access Required access pattern for this file -# @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1137,6 +1112,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1148,6 +1124,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1159,6 +1136,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1166,11 +1144,12 @@ class Image # Load gif with libnsgif. # @param filename [String] Filename to load from # @param opts [Hash] Set of options -# @option opts [Integer] :n Load this many pages -# @option opts [Integer] :page Load this page from the file +# @option opts [Integer] :n Number of pages to load, -1 for all +# @option opts [Integer] :page First page to load # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1178,11 +1157,12 @@ class Image # Load gif with libnsgif. # @param buffer [VipsBlob] Buffer to load from # @param opts [Hash] Set of options -# @option opts [Integer] :n Load this many pages -# @option opts [Integer] :page Load this page from the file +# @option opts [Integer] :n Number of pages to load, -1 for all +# @option opts [Integer] :page First page to load # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1190,11 +1170,12 @@ class Image # Load gif from source. # @param source [Vips::Source] Source to load from # @param opts [Hash] Set of options -# @option opts [Integer] :n Load this many pages -# @option opts [Integer] :page Load this page from the file +# @option opts [Integer] :n Number of pages to load, -1 for all +# @option opts [Integer] :page First page to load # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1206,6 +1187,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1217,6 +1199,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1228,6 +1211,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1238,6 +1222,7 @@ class Image # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1247,9 +1232,11 @@ class Image # @param opts [Hash] Set of options # @option opts [Integer] :shrink Shrink factor on load # @option opts [Boolean] :autorotate Rotate image using exif orientation +# @option opts [Boolean] :unlimited Remove all denial of service limits # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1259,9 +1246,11 @@ class Image # @param opts [Hash] Set of options # @option opts [Integer] :shrink Shrink factor on load # @option opts [Boolean] :autorotate Rotate image using exif orientation +# @option opts [Boolean] :unlimited Remove all denial of service limits # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1271,9 +1260,11 @@ class Image # @param opts [Hash] Set of options # @option opts [Integer] :shrink Shrink factor on load # @option opts [Boolean] :autorotate Rotate image using exif orientation +# @option opts [Boolean] :unlimited Remove all denial of service limits # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1281,12 +1272,13 @@ class Image # Load webp from file. # @param filename [String] Filename to load from # @param opts [Hash] Set of options -# @option opts [Integer] :page Load this page from the file -# @option opts [Integer] :n Load this many pages -# @option opts [Float] :scale Scale factor on load +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all +# @option opts [Float] :scale Factor to scale by # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1294,12 +1286,13 @@ class Image # Load webp from buffer. # @param buffer [VipsBlob] Buffer to load from # @param opts [Hash] Set of options -# @option opts [Integer] :page Load this page from the file -# @option opts [Integer] :n Load this many pages -# @option opts [Float] :scale Scale factor on load +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all +# @option opts [Float] :scale Factor to scale by # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1307,12 +1300,13 @@ class Image # Load webp from source. # @param source [Vips::Source] Source to load from # @param opts [Hash] Set of options -# @option opts [Integer] :page Load this page from the file -# @option opts [Integer] :n Load this many pages -# @option opts [Float] :scale Scale factor on load +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all +# @option opts [Float] :scale Factor to scale by # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1320,13 +1314,14 @@ class Image # Load tiff from file. # @param filename [String] Filename to load from # @param opts [Hash] Set of options -# @option opts [Integer] :page Load this page from the image -# @option opts [Integer] :subifd Select subifd index -# @option opts [Integer] :n Load this many pages +# @option opts [Integer] :page First page to load +# @option opts [Integer] :subifd Subifd index +# @option opts [Integer] :n Number of pages to load, -1 for all # @option opts [Boolean] :autorotate Rotate image using orientation tag # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1334,13 +1329,14 @@ class Image # Load tiff from buffer. # @param buffer [VipsBlob] Buffer to load from # @param opts [Hash] Set of options -# @option opts [Integer] :page Load this page from the image -# @option opts [Integer] :subifd Select subifd index -# @option opts [Integer] :n Load this many pages +# @option opts [Integer] :page First page to load +# @option opts [Integer] :subifd Subifd index +# @option opts [Integer] :n Number of pages to load, -1 for all # @option opts [Boolean] :autorotate Rotate image using orientation tag # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1348,13 +1344,69 @@ class Image # Load tiff from source. # @param source [Vips::Source] Source to load from # @param opts [Hash] Set of options -# @option opts [Integer] :page Load this page from the image -# @option opts [Integer] :subifd Select subifd index -# @option opts [Integer] :n Load this many pages +# @option opts [Integer] :page First page to load +# @option opts [Integer] :subifd Subifd index +# @option opts [Integer] :n Number of pages to load, -1 for all # @option opts [Boolean] :autorotate Rotate image using orientation tag # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation +# @option opts [Vips::ForeignFlags] :flags Output Flags for this file +# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items + +# @!method self.fitsload(filename, **opts) +# Load a fits image. +# @param filename [String] Filename to load from +# @param opts [Hash] Set of options +# @option opts [Boolean] :memory Force open via memory +# @option opts [Vips::Access] :access Required access pattern for this file +# @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation +# @option opts [Vips::ForeignFlags] :flags Output Flags for this file +# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items + +# @!method self.fitsload_source(source, **opts) +# Load fits from a source. +# @param source [Vips::Source] Source to load from +# @param opts [Hash] Set of options +# @option opts [Boolean] :memory Force open via memory +# @option opts [Vips::Access] :access Required access pattern for this file +# @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation +# @option opts [Vips::ForeignFlags] :flags Output Flags for this file +# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items + +# @!method self.openexrload(filename, **opts) +# Load an openexr image. +# @param filename [String] Filename to load from +# @param opts [Hash] Set of options +# @option opts [Boolean] :memory Force open via memory +# @option opts [Vips::Access] :access Required access pattern for this file +# @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation +# @option opts [Vips::ForeignFlags] :flags Output Flags for this file +# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items + +# @!method self.niftiload(filename, **opts) +# Load nifti volume. +# @param filename [String] Filename to load from +# @param opts [Hash] Set of options +# @option opts [Boolean] :memory Force open via memory +# @option opts [Vips::Access] :access Required access pattern for this file +# @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation +# @option opts [Vips::ForeignFlags] :flags Output Flags for this file +# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items + +# @!method self.niftiload_source(source, **opts) +# Load nifti volumes. +# @param source [Vips::Source] Source to load from +# @param opts [Hash] Set of options +# @option opts [Boolean] :memory Force open via memory +# @option opts [Vips::Access] :access Required access pattern for this file +# @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1362,13 +1414,15 @@ class Image # Load file with openslide. # @param filename [String] Filename to load from # @param opts [Hash] Set of options -# @option opts [Boolean] :attach_associated Attach all associated images # @option opts [Integer] :level Load this level from the file # @option opts [Boolean] :autocrop Crop to image bounds # @option opts [String] :associated Load this associated image +# @option opts [Boolean] :attach_associated Attach all associated images +# @option opts [Boolean] :rgb Output RGB (not RGBA) # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1376,128 +1430,178 @@ class Image # Load source with openslide. # @param source [Vips::Source] Source to load from # @param opts [Hash] Set of options -# @option opts [Boolean] :attach_associated Attach all associated images # @option opts [Integer] :level Load this level from the file # @option opts [Boolean] :autocrop Crop to image bounds # @option opts [String] :associated Load this associated image +# @option opts [Boolean] :attach_associated Attach all associated images +# @option opts [Boolean] :rgb Output RGB (not RGBA) # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items -# @!method self.magickload(filename, **opts) -# Load file with imagemagick. +# @!method self.heifload(filename, **opts) +# Load a heif image. # @param filename [String] Filename to load from # @param opts [Hash] Set of options -# @option opts [String] :density Canvas resolution for rendering vector formats like SVG -# @option opts [Integer] :page Load this page from the file -# @option opts [Integer] :n Load this many pages +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all +# @option opts [Boolean] :thumbnail Fetch thumbnail image +# @option opts [Boolean] :unlimited Remove all denial of service limits # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items -# @!method self.magickload_buffer(buffer, **opts) -# Load buffer with imagemagick. +# @!method self.heifload_buffer(buffer, **opts) +# Load a heif image. # @param buffer [VipsBlob] Buffer to load from # @param opts [Hash] Set of options -# @option opts [String] :density Canvas resolution for rendering vector formats like SVG -# @option opts [Integer] :page Load this page from the file -# @option opts [Integer] :n Load this many pages +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all +# @option opts [Boolean] :thumbnail Fetch thumbnail image +# @option opts [Boolean] :unlimited Remove all denial of service limits # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items -# @!method self.fitsload(filename, **opts) -# Load a fits image. +# @!method self.heifload_source(source, **opts) +# Load a heif image. +# @param source [Vips::Source] Source to load from +# @param opts [Hash] Set of options +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all +# @option opts [Boolean] :thumbnail Fetch thumbnail image +# @option opts [Boolean] :unlimited Remove all denial of service limits +# @option opts [Boolean] :memory Force open via memory +# @option opts [Vips::Access] :access Required access pattern for this file +# @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation +# @option opts [Vips::ForeignFlags] :flags Output Flags for this file +# @return [Vips::Image, Hash Object>] Output image, Hash of optional output items + +# @!method self.jxlload(filename, **opts) +# Load jpeg-xl image. # @param filename [String] Filename to load from # @param opts [Hash] Set of options +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items -# @!method self.fitsload_source(source, **opts) -# Load fits from a source. -# @param source [Vips::Source] Source to load from +# @!method self.jxlload_buffer(buffer, **opts) +# Load jpeg-xl image. +# @param buffer [VipsBlob] Buffer to load from # @param opts [Hash] Set of options +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items -# @!method self.openexrload(filename, **opts) -# Load an openexr image. -# @param filename [String] Filename to load from +# @!method self.jxlload_source(source, **opts) +# Load jpeg-xl image. +# @param source [Vips::Source] Source to load from # @param opts [Hash] Set of options +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items -# @!method self.niftiload(filename, **opts) -# Load nifti volume. +# @!method self.pdfload(filename, **opts) +# Load pdf from file. # @param filename [String] Filename to load from # @param opts [Hash] Set of options +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all +# @option opts [Float] :dpi DPI to render at +# @option opts [Float] :scale Factor to scale by +# @option opts [Array] :background Background colour +# @option opts [String] :password Password to decrypt with # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items -# @!method self.niftiload_source(source, **opts) -# Load nifti volumes. -# @param source [Vips::Source] Source to load from +# @!method self.pdfload_buffer(buffer, **opts) +# Load pdf from buffer. +# @param buffer [VipsBlob] Buffer to load from # @param opts [Hash] Set of options +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all +# @option opts [Float] :dpi DPI to render at +# @option opts [Float] :scale Factor to scale by +# @option opts [Array] :background Background colour +# @option opts [String] :password Password to decrypt with # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items -# @!method self.heifload(filename, **opts) -# Load a heif image. -# @param filename [String] Filename to load from +# @!method self.pdfload_source(source, **opts) +# Load pdf from source. +# @param source [Vips::Source] Source to load from # @param opts [Hash] Set of options -# @option opts [Integer] :page Load this page from the file -# @option opts [Integer] :n Load this many pages -# @option opts [Boolean] :thumbnail Fetch thumbnail image +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all +# @option opts [Float] :dpi DPI to render at +# @option opts [Float] :scale Factor to scale by +# @option opts [Array] :background Background colour +# @option opts [String] :password Password to decrypt with # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items -# @!method self.heifload_buffer(buffer, **opts) -# Load a heif image. -# @param buffer [VipsBlob] Buffer to load from +# @!method self.magickload(filename, **opts) +# Load file with imagemagick. +# @param filename [String] Filename to load from # @param opts [Hash] Set of options -# @option opts [Integer] :page Load this page from the file -# @option opts [Integer] :n Load this many pages -# @option opts [Boolean] :thumbnail Fetch thumbnail image +# @option opts [String] :density Canvas resolution for rendering vector formats like SVG +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items -# @!method self.heifload_source(source, **opts) -# Load a heif image. -# @param source [Vips::Source] Source to load from +# @!method self.magickload_buffer(buffer, **opts) +# Load buffer with imagemagick. +# @param buffer [VipsBlob] Buffer to load from # @param opts [Hash] Set of options -# @option opts [Integer] :page Load this page from the file -# @option opts [Integer] :n Load this many pages -# @option opts [Boolean] :thumbnail Fetch thumbnail image +# @option opts [String] :density Canvas resolution for rendering vector formats like SVG +# @option opts [Integer] :page First page to load +# @option opts [Integer] :n Number of pages to load, -1 for all # @option opts [Boolean] :memory Force open via memory # @option opts [Vips::Access] :access Required access pattern for this file # @option opts [Vips::FailOn] :fail_on Error level to fail on +# @option opts [Boolean] :revalidate Don't use a cached result for this operation # @option opts [Vips::ForeignFlags] :flags Output Flags for this file # @return [Vips::Image, Hash Object>] Output image, Hash of optional output items @@ -1506,9 +1610,10 @@ class Image # @param filename [String] Filename to save to # @param opts [Hash] Set of options # @option opts [String] :separator Separator characters -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method csvsave_target(target, **opts) @@ -1516,71 +1621,88 @@ class Image # @param target [Vips::Target] Target to save to # @param opts [Hash] Set of options # @option opts [String] :separator Separator characters -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method matrixsave(filename, **opts) # Save image to matrix. # @param filename [String] Filename to save to # @param opts [Hash] Set of options -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method matrixsave_target(target, **opts) # Save image to matrix. # @param target [Vips::Target] Target to save to # @param opts [Hash] Set of options -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method matrixprint(**opts) # Print matrix. # @param opts [Hash] Set of options -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method rawsave(filename, **opts) # Save image to raw file. # @param filename [String] Filename to save to # @param opts [Hash] Set of options -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] -# @!method rawsave_fd(fd, **opts) -# Write raw image to file descriptor. -# @param fd [Integer] File descriptor to write to +# @!method rawsave_buffer(**opts) +# Write raw image to buffer. # @param opts [Hash] Set of options -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed +# @return [VipsBlob] Buffer to save to + +# @!method rawsave_target(target, **opts) +# Write raw image to target. +# @param target [Vips::Target] Target to save to +# @param opts [Hash] Set of options +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain +# @option opts [Array] :background Background value +# @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method vipssave(filename, **opts) # Save image to file in vips format. # @param filename [String] Filename to save to # @param opts [Hash] Set of options -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method vipssave_target(target, **opts) # Save image to target in vips format. # @param target [Vips::Target] Target to save to # @param opts [Hash] Set of options -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method ppmsave(filename, **opts) @@ -1588,11 +1710,12 @@ class Image # @param filename [String] Filename to save to # @param opts [Hash] Set of options # @option opts [Vips::ForeignPpmFormat] :format Format to save in -# @option opts [Boolean] :ascii save as ascii -# @option opts [Integer] :bitdepth set to 1 to write as a 1 bit image -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Boolean] :ascii Save as ascii +# @option opts [Integer] :bitdepth Set to 1 to write as a 1 bit image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method ppmsave_target(target, **opts) @@ -1600,92 +1723,56 @@ class Image # @param target [Vips::Target] Target to save to # @param opts [Hash] Set of options # @option opts [Vips::ForeignPpmFormat] :format Format to save in -# @option opts [Boolean] :ascii save as ascii -# @option opts [Integer] :bitdepth set to 1 to write as a 1 bit image -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Boolean] :ascii Save as ascii +# @option opts [Integer] :bitdepth Set to 1 to write as a 1 bit image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method radsave(filename, **opts) # Save image to radiance file. # @param filename [String] Filename to save to # @param opts [Hash] Set of options -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method radsave_buffer(**opts) # Save image to radiance buffer. # @param opts [Hash] Set of options -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [VipsBlob] Buffer to save to # @!method radsave_target(target, **opts) # Save image to radiance target. # @param target [Vips::Target] Target to save to # @param opts [Hash] Set of options -# @option opts [Boolean] :strip Strip all metadata from image -# @option opts [Array] :background Background value -# @option opts [Integer] :page_height Set page height for multipage save -# @return [nil] - -# @!method jxlsave(filename, **opts) -# Save image in jpeg-xl format. -# @param filename [String] Filename to load from -# @param opts [Hash] Set of options -# @option opts [Integer] :tier Decode speed tier -# @option opts [Float] :distance Target butteraugli distance -# @option opts [Integer] :effort Encoding effort -# @option opts [Boolean] :lossless Enable lossless compression -# @option opts [Integer] :Q Quality factor -# @option opts [Boolean] :strip Strip all metadata from image -# @option opts [Array] :background Background value -# @option opts [Integer] :page_height Set page height for multipage save -# @return [nil] - -# @!method jxlsave_buffer(**opts) -# Save image in jpeg-xl format. -# @param opts [Hash] Set of options -# @option opts [Integer] :tier Decode speed tier -# @option opts [Float] :distance Target butteraugli distance -# @option opts [Integer] :effort Encoding effort -# @option opts [Boolean] :lossless Enable lossless compression -# @option opts [Integer] :Q Quality factor -# @option opts [Boolean] :strip Strip all metadata from image -# @option opts [Array] :background Background value -# @option opts [Integer] :page_height Set page height for multipage save -# @return [VipsBlob] Buffer to save to - -# @!method jxlsave_target(target, **opts) -# Save image in jpeg-xl format. -# @param target [Vips::Target] Target to save to -# @param opts [Hash] Set of options -# @option opts [Integer] :tier Decode speed tier -# @option opts [Float] :distance Target butteraugli distance -# @option opts [Integer] :effort Encoding effort -# @option opts [Boolean] :lossless Enable lossless compression -# @option opts [Integer] :Q Quality factor -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method jp2ksave(filename, **opts) # Save image in jpeg2000 format. -# @param filename [String] Filename to load from +# @param filename [String] Filename to save to # @param opts [Hash] Set of options # @option opts [Integer] :tile_width Tile width in pixels # @option opts [Integer] :tile_height Tile height in pixels # @option opts [Boolean] :lossless Enable lossless compression # @option opts [Integer] :Q Q factor # @option opts [Vips::ForeignSubsample] :subsample_mode Select chroma subsample operation mode -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method jp2ksave_buffer(**opts) @@ -1696,9 +1783,10 @@ class Image # @option opts [Boolean] :lossless Enable lossless compression # @option opts [Integer] :Q Q factor # @option opts [Vips::ForeignSubsample] :subsample_mode Select chroma subsample operation mode -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [VipsBlob] Buffer to save to # @!method jp2ksave_target(target, **opts) @@ -1710,9 +1798,10 @@ class Image # @option opts [Boolean] :lossless Enable lossless compression # @option opts [Integer] :Q Q factor # @option opts [Vips::ForeignSubsample] :subsample_mode Select chroma subsample operation mode -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method gifsave(filename, **opts) @@ -1722,9 +1811,14 @@ class Image # @option opts [Float] :dither Amount of dithering # @option opts [Integer] :effort Quantisation effort # @option opts [Integer] :bitdepth Number of bits per pixel -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Float] :interframe_maxerror Maximum inter-frame error for transparency +# @option opts [Boolean] :reuse Reuse palette from input +# @option opts [Float] :interpalette_maxerror Maximum inter-palette error for palette reusage +# @option opts [Boolean] :interlace Generate an interlaced (progressive) GIF +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method gifsave_buffer(**opts) @@ -1733,9 +1827,14 @@ class Image # @option opts [Float] :dither Amount of dithering # @option opts [Integer] :effort Quantisation effort # @option opts [Integer] :bitdepth Number of bits per pixel -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Float] :interframe_maxerror Maximum inter-frame error for transparency +# @option opts [Boolean] :reuse Reuse palette from input +# @option opts [Float] :interpalette_maxerror Maximum inter-palette error for palette reusage +# @option opts [Boolean] :interlace Generate an interlaced (progressive) GIF +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [VipsBlob] Buffer to save to # @!method gifsave_target(target, **opts) @@ -1745,16 +1844,21 @@ class Image # @option opts [Float] :dither Amount of dithering # @option opts [Integer] :effort Quantisation effort # @option opts [Integer] :bitdepth Number of bits per pixel -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Float] :interframe_maxerror Maximum inter-frame error for transparency +# @option opts [Boolean] :reuse Reuse palette from input +# @option opts [Float] :interpalette_maxerror Maximum inter-palette error for palette reusage +# @option opts [Boolean] :interlace Generate an interlaced (progressive) GIF +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method dzsave(filename, **opts) # Save image to deepzoom file. # @param filename [String] Filename to save to # @param opts [Hash] Set of options -# @option opts [String] :basename Base name to save to +# @option opts [String] :imagename Image name # @option opts [Vips::ForeignDzLayout] :layout Directory layout # @option opts [String] :suffix Filename suffix for tiles # @option opts [Integer] :overlap Tile overlap in pixels @@ -1763,21 +1867,21 @@ class Image # @option opts [Vips::ForeignDzDepth] :depth Pyramid depth # @option opts [Vips::Angle] :angle Rotate image during save # @option opts [Vips::ForeignDzContainer] :container Pyramid container type -# @option opts [Boolean] :properties Write a properties file to the output directory # @option opts [Integer] :compression ZIP deflate compression level # @option opts [Vips::RegionShrink] :region_shrink Method to shrink regions # @option opts [Integer] :skip_blanks Skip tiles which are nearly equal to the background -# @option opts [Boolean] :no_strip Don't strip tile metadata # @option opts [String] :id Resource ID -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Integer] :Q Q factor +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method dzsave_buffer(**opts) # Save image to dz buffer. # @param opts [Hash] Set of options -# @option opts [String] :basename Base name to save to +# @option opts [String] :imagename Image name # @option opts [Vips::ForeignDzLayout] :layout Directory layout # @option opts [String] :suffix Filename suffix for tiles # @option opts [Integer] :overlap Tile overlap in pixels @@ -1786,50 +1890,74 @@ class Image # @option opts [Vips::ForeignDzDepth] :depth Pyramid depth # @option opts [Vips::Angle] :angle Rotate image during save # @option opts [Vips::ForeignDzContainer] :container Pyramid container type -# @option opts [Boolean] :properties Write a properties file to the output directory # @option opts [Integer] :compression ZIP deflate compression level # @option opts [Vips::RegionShrink] :region_shrink Method to shrink regions # @option opts [Integer] :skip_blanks Skip tiles which are nearly equal to the background -# @option opts [Boolean] :no_strip Don't strip tile metadata # @option opts [String] :id Resource ID -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Integer] :Q Q factor +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [VipsBlob] Buffer to save to +# @!method dzsave_target(target, **opts) +# Save image to deepzoom target. +# @param target [Vips::Target] Target to save to +# @param opts [Hash] Set of options +# @option opts [String] :imagename Image name +# @option opts [Vips::ForeignDzLayout] :layout Directory layout +# @option opts [String] :suffix Filename suffix for tiles +# @option opts [Integer] :overlap Tile overlap in pixels +# @option opts [Integer] :tile_size Tile size in pixels +# @option opts [Boolean] :centre Center image in tile +# @option opts [Vips::ForeignDzDepth] :depth Pyramid depth +# @option opts [Vips::Angle] :angle Rotate image during save +# @option opts [Vips::ForeignDzContainer] :container Pyramid container type +# @option opts [Integer] :compression ZIP deflate compression level +# @option opts [Vips::RegionShrink] :region_shrink Method to shrink regions +# @option opts [Integer] :skip_blanks Skip tiles which are nearly equal to the background +# @option opts [String] :id Resource ID +# @option opts [Integer] :Q Q factor +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain +# @option opts [Array] :background Background value +# @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed +# @return [nil] + # @!method pngsave(filename, **opts) -# Save image to png file. +# Save image to file as png. # @param filename [String] Filename to save to # @param opts [Hash] Set of options # @option opts [Integer] :compression Compression factor # @option opts [Boolean] :interlace Interlace image -# @option opts [String] :profile ICC profile to embed -# @option opts [Vips::ForeignPngFilter] :filter libpng row filter flag(s) +# @option opts [Vips::ForeignPngFilter] :filter libspng row filter flag(s) # @option opts [Boolean] :palette Quantise to 8bpp palette # @option opts [Integer] :Q Quantisation quality # @option opts [Float] :dither Amount of dithering -# @option opts [Integer] :bitdepth Write as a 1, 2, 4 or 8 bit image +# @option opts [Integer] :bitdepth Write as a 1, 2, 4, 8 or 16 bit image # @option opts [Integer] :effort Quantisation CPU effort -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method pngsave_buffer(**opts) -# Save image to png buffer. +# Save image to buffer as png. # @param opts [Hash] Set of options # @option opts [Integer] :compression Compression factor # @option opts [Boolean] :interlace Interlace image -# @option opts [String] :profile ICC profile to embed -# @option opts [Vips::ForeignPngFilter] :filter libpng row filter flag(s) +# @option opts [Vips::ForeignPngFilter] :filter libspng row filter flag(s) # @option opts [Boolean] :palette Quantise to 8bpp palette # @option opts [Integer] :Q Quantisation quality # @option opts [Float] :dither Amount of dithering -# @option opts [Integer] :bitdepth Write as a 1, 2, 4 or 8 bit image +# @option opts [Integer] :bitdepth Write as a 1, 2, 4, 8 or 16 bit image # @option opts [Integer] :effort Quantisation CPU effort -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [VipsBlob] Buffer to save to # @!method pngsave_target(target, **opts) @@ -1838,16 +1966,16 @@ class Image # @param opts [Hash] Set of options # @option opts [Integer] :compression Compression factor # @option opts [Boolean] :interlace Interlace image -# @option opts [String] :profile ICC profile to embed -# @option opts [Vips::ForeignPngFilter] :filter libpng row filter flag(s) +# @option opts [Vips::ForeignPngFilter] :filter libspng row filter flag(s) # @option opts [Boolean] :palette Quantise to 8bpp palette # @option opts [Integer] :Q Quantisation quality # @option opts [Float] :dither Amount of dithering -# @option opts [Integer] :bitdepth Write as a 1, 2, 4 or 8 bit image +# @option opts [Integer] :bitdepth Write as a 1, 2, 4, 8 or 16 bit image # @option opts [Integer] :effort Quantisation CPU effort -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method jpegsave(filename, **opts) @@ -1855,7 +1983,6 @@ class Image # @param filename [String] Filename to save to # @param opts [Hash] Set of options # @option opts [Integer] :Q Q factor -# @option opts [String] :profile ICC profile to embed # @option opts [Boolean] :optimize_coding Compute optimal Huffman coding tables # @option opts [Boolean] :interlace Generate an interlaced (progressive) jpeg # @option opts [Boolean] :trellis_quant Apply trellis quantisation to each 8x8 block @@ -1864,16 +1991,16 @@ class Image # @option opts [Integer] :quant_table Use predefined quantization table with given index # @option opts [Vips::ForeignSubsample] :subsample_mode Select chroma subsample operation mode # @option opts [Integer] :restart_interval Add restart markers every specified number of mcu -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method jpegsave_buffer(**opts) # Save image to jpeg buffer. # @param opts [Hash] Set of options # @option opts [Integer] :Q Q factor -# @option opts [String] :profile ICC profile to embed # @option opts [Boolean] :optimize_coding Compute optimal Huffman coding tables # @option opts [Boolean] :interlace Generate an interlaced (progressive) jpeg # @option opts [Boolean] :trellis_quant Apply trellis quantisation to each 8x8 block @@ -1882,9 +2009,10 @@ class Image # @option opts [Integer] :quant_table Use predefined quantization table with given index # @option opts [Vips::ForeignSubsample] :subsample_mode Select chroma subsample operation mode # @option opts [Integer] :restart_interval Add restart markers every specified number of mcu -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [VipsBlob] Buffer to save to # @!method jpegsave_target(target, **opts) @@ -1892,7 +2020,6 @@ class Image # @param target [Vips::Target] Target to save to # @param opts [Hash] Set of options # @option opts [Integer] :Q Q factor -# @option opts [String] :profile ICC profile to embed # @option opts [Boolean] :optimize_coding Compute optimal Huffman coding tables # @option opts [Boolean] :interlace Generate an interlaced (progressive) jpeg # @option opts [Boolean] :trellis_quant Apply trellis quantisation to each 8x8 block @@ -1901,16 +2028,16 @@ class Image # @option opts [Integer] :quant_table Use predefined quantization table with given index # @option opts [Vips::ForeignSubsample] :subsample_mode Select chroma subsample operation mode # @option opts [Integer] :restart_interval Add restart markers every specified number of mcu -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method jpegsave_mime(**opts) # Save image to jpeg mime. # @param opts [Hash] Set of options # @option opts [Integer] :Q Q factor -# @option opts [String] :profile ICC profile to embed # @option opts [Boolean] :optimize_coding Compute optimal Huffman coding tables # @option opts [Boolean] :interlace Generate an interlaced (progressive) jpeg # @option opts [Boolean] :trellis_quant Apply trellis quantisation to each 8x8 block @@ -1919,68 +2046,104 @@ class Image # @option opts [Integer] :quant_table Use predefined quantization table with given index # @option opts [Vips::ForeignSubsample] :subsample_mode Select chroma subsample operation mode # @option opts [Integer] :restart_interval Add restart markers every specified number of mcu -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method webpsave(filename, **opts) -# Save image to webp file. +# Save as webp. # @param filename [String] Filename to save to # @param opts [Hash] Set of options # @option opts [Integer] :Q Q factor -# @option opts [Boolean] :lossless enable lossless compression +# @option opts [Boolean] :lossless Enable lossless compression # @option opts [Vips::ForeignWebpPreset] :preset Preset for lossy compression # @option opts [Boolean] :smart_subsample Enable high quality chroma subsampling # @option opts [Boolean] :near_lossless Enable preprocessing in lossless mode (uses Q) # @option opts [Integer] :alpha_q Change alpha plane fidelity for lossy compression -# @option opts [Boolean] :min_size Optimise for minium size +# @option opts [Boolean] :min_size Optimise for minimum size # @option opts [Integer] :kmin Minimum number of frames between key frames # @option opts [Integer] :kmax Maximum number of frames between key frames # @option opts [Integer] :effort Level of CPU effort to reduce file size -# @option opts [String] :profile ICC profile to embed -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Integer] :target_size Desired target size in bytes +# @option opts [Boolean] :mixed Allow mixed encoding (might reduce file size) +# @option opts [Boolean] :smart_deblock Enable auto-adjusting of the deblocking filter +# @option opts [Integer] :passes Number of entropy-analysis passes (in [1..10]) +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method webpsave_buffer(**opts) -# Save image to webp buffer. +# Save as webp. # @param opts [Hash] Set of options # @option opts [Integer] :Q Q factor -# @option opts [Boolean] :lossless enable lossless compression +# @option opts [Boolean] :lossless Enable lossless compression # @option opts [Vips::ForeignWebpPreset] :preset Preset for lossy compression # @option opts [Boolean] :smart_subsample Enable high quality chroma subsampling # @option opts [Boolean] :near_lossless Enable preprocessing in lossless mode (uses Q) # @option opts [Integer] :alpha_q Change alpha plane fidelity for lossy compression -# @option opts [Boolean] :min_size Optimise for minium size +# @option opts [Boolean] :min_size Optimise for minimum size # @option opts [Integer] :kmin Minimum number of frames between key frames # @option opts [Integer] :kmax Maximum number of frames between key frames # @option opts [Integer] :effort Level of CPU effort to reduce file size -# @option opts [String] :profile ICC profile to embed -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Integer] :target_size Desired target size in bytes +# @option opts [Boolean] :mixed Allow mixed encoding (might reduce file size) +# @option opts [Boolean] :smart_deblock Enable auto-adjusting of the deblocking filter +# @option opts [Integer] :passes Number of entropy-analysis passes (in [1..10]) +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [VipsBlob] Buffer to save to # @!method webpsave_target(target, **opts) -# Save image to webp target. +# Save as webp. # @param target [Vips::Target] Target to save to # @param opts [Hash] Set of options # @option opts [Integer] :Q Q factor -# @option opts [Boolean] :lossless enable lossless compression +# @option opts [Boolean] :lossless Enable lossless compression +# @option opts [Vips::ForeignWebpPreset] :preset Preset for lossy compression +# @option opts [Boolean] :smart_subsample Enable high quality chroma subsampling +# @option opts [Boolean] :near_lossless Enable preprocessing in lossless mode (uses Q) +# @option opts [Integer] :alpha_q Change alpha plane fidelity for lossy compression +# @option opts [Boolean] :min_size Optimise for minimum size +# @option opts [Integer] :kmin Minimum number of frames between key frames +# @option opts [Integer] :kmax Maximum number of frames between key frames +# @option opts [Integer] :effort Level of CPU effort to reduce file size +# @option opts [Integer] :target_size Desired target size in bytes +# @option opts [Boolean] :mixed Allow mixed encoding (might reduce file size) +# @option opts [Boolean] :smart_deblock Enable auto-adjusting of the deblocking filter +# @option opts [Integer] :passes Number of entropy-analysis passes (in [1..10]) +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain +# @option opts [Array] :background Background value +# @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed +# @return [nil] + +# @!method webpsave_mime(**opts) +# Save image to webp mime. +# @param opts [Hash] Set of options +# @option opts [Integer] :Q Q factor +# @option opts [Boolean] :lossless Enable lossless compression # @option opts [Vips::ForeignWebpPreset] :preset Preset for lossy compression # @option opts [Boolean] :smart_subsample Enable high quality chroma subsampling # @option opts [Boolean] :near_lossless Enable preprocessing in lossless mode (uses Q) # @option opts [Integer] :alpha_q Change alpha plane fidelity for lossy compression -# @option opts [Boolean] :min_size Optimise for minium size +# @option opts [Boolean] :min_size Optimise for minimum size # @option opts [Integer] :kmin Minimum number of frames between key frames # @option opts [Integer] :kmax Maximum number of frames between key frames # @option opts [Integer] :effort Level of CPU effort to reduce file size -# @option opts [String] :profile ICC profile to embed -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Integer] :target_size Desired target size in bytes +# @option opts [Boolean] :mixed Allow mixed encoding (might reduce file size) +# @option opts [Boolean] :smart_deblock Enable auto-adjusting of the deblocking filter +# @option opts [Integer] :passes Number of entropy-analysis passes (in [1..10]) +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method tiffsave(filename, **opts) @@ -1990,7 +2153,6 @@ class Image # @option opts [Vips::ForeignTiffCompression] :compression Compression for this file # @option opts [Integer] :Q Q factor # @option opts [Vips::ForeignTiffPredictor] :predictor Compression prediction -# @option opts [String] :profile ICC profile to embed # @option opts [Boolean] :tile Write a tiled tiff # @option opts [Integer] :tile_width Tile width in pixels # @option opts [Integer] :tile_height Tile height in pixels @@ -2003,14 +2165,15 @@ class Image # @option opts [Boolean] :bigtiff Write a bigtiff image # @option opts [Boolean] :properties Write a properties document to IMAGEDESCRIPTION # @option opts [Vips::RegionShrink] :region_shrink Method to shrink regions -# @option opts [Integer] :level ZSTD compression level +# @option opts [Integer] :level Deflate (1-9, default 6) or ZSTD (1-22, default 9) compression level # @option opts [Boolean] :lossless Enable WEBP lossless mode # @option opts [Vips::ForeignDzDepth] :depth Pyramid depth # @option opts [Boolean] :subifd Save pyr layers as sub-IFDs # @option opts [Boolean] :premultiply Save with premultiplied alpha -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method tiffsave_buffer(**opts) @@ -2019,7 +2182,6 @@ class Image # @option opts [Vips::ForeignTiffCompression] :compression Compression for this file # @option opts [Integer] :Q Q factor # @option opts [Vips::ForeignTiffPredictor] :predictor Compression prediction -# @option opts [String] :profile ICC profile to embed # @option opts [Boolean] :tile Write a tiled tiff # @option opts [Integer] :tile_width Tile width in pixels # @option opts [Integer] :tile_height Tile height in pixels @@ -2032,57 +2194,65 @@ class Image # @option opts [Boolean] :bigtiff Write a bigtiff image # @option opts [Boolean] :properties Write a properties document to IMAGEDESCRIPTION # @option opts [Vips::RegionShrink] :region_shrink Method to shrink regions -# @option opts [Integer] :level ZSTD compression level +# @option opts [Integer] :level Deflate (1-9, default 6) or ZSTD (1-22, default 9) compression level # @option opts [Boolean] :lossless Enable WEBP lossless mode # @option opts [Vips::ForeignDzDepth] :depth Pyramid depth # @option opts [Boolean] :subifd Save pyr layers as sub-IFDs # @option opts [Boolean] :premultiply Save with premultiplied alpha -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [VipsBlob] Buffer to save to -# @!method magicksave(filename, **opts) -# Save file with imagemagick. -# @param filename [String] Filename to save to +# @!method tiffsave_target(target, **opts) +# Save image to tiff target. +# @param target [Vips::Target] Target to save to # @param opts [Hash] Set of options -# @option opts [String] :format Format to save in -# @option opts [Integer] :quality Quality to use -# @option opts [Boolean] :optimize_gif_frames Apply GIF frames optimization -# @option opts [Boolean] :optimize_gif_transparency Apply GIF transparency optimization -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignTiffCompression] :compression Compression for this file +# @option opts [Integer] :Q Q factor +# @option opts [Vips::ForeignTiffPredictor] :predictor Compression prediction +# @option opts [Boolean] :tile Write a tiled tiff +# @option opts [Integer] :tile_width Tile width in pixels +# @option opts [Integer] :tile_height Tile height in pixels +# @option opts [Boolean] :pyramid Write a pyramidal tiff +# @option opts [Boolean] :miniswhite Use 0 for white in 1-bit images +# @option opts [Integer] :bitdepth Write as a 1, 2, 4 or 8 bit image +# @option opts [Vips::ForeignTiffResunit] :resunit Resolution unit +# @option opts [Float] :xres Horizontal resolution in pixels/mm +# @option opts [Float] :yres Vertical resolution in pixels/mm +# @option opts [Boolean] :bigtiff Write a bigtiff image +# @option opts [Boolean] :properties Write a properties document to IMAGEDESCRIPTION +# @option opts [Vips::RegionShrink] :region_shrink Method to shrink regions +# @option opts [Integer] :level Deflate (1-9, default 6) or ZSTD (1-22, default 9) compression level +# @option opts [Boolean] :lossless Enable WEBP lossless mode +# @option opts [Vips::ForeignDzDepth] :depth Pyramid depth +# @option opts [Boolean] :subifd Save pyr layers as sub-IFDs +# @option opts [Boolean] :premultiply Save with premultiplied alpha +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] -# @!method magicksave_buffer(**opts) -# Save image to magick buffer. -# @param opts [Hash] Set of options -# @option opts [String] :format Format to save in -# @option opts [Integer] :quality Quality to use -# @option opts [Boolean] :optimize_gif_frames Apply GIF frames optimization -# @option opts [Boolean] :optimize_gif_transparency Apply GIF transparency optimization -# @option opts [Boolean] :strip Strip all metadata from image -# @option opts [Array] :background Background value -# @option opts [Integer] :page_height Set page height for multipage save -# @return [VipsBlob] Buffer to save to - # @!method fitssave(filename, **opts) # Save image to fits file. # @param filename [String] Filename to save to # @param opts [Hash] Set of options -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method niftisave(filename, **opts) # Save image to nifti file. # @param filename [String] Filename to save to # @param opts [Hash] Set of options -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method heifsave(filename, **opts) @@ -2090,26 +2260,32 @@ class Image # @param filename [String] Filename to save to # @param opts [Hash] Set of options # @option opts [Integer] :Q Q factor +# @option opts [Integer] :bitdepth Number of bits per pixel # @option opts [Boolean] :lossless Enable lossless compression # @option opts [Vips::ForeignHeifCompression] :compression Compression format # @option opts [Integer] :effort CPU effort # @option opts [Vips::ForeignSubsample] :subsample_mode Select chroma subsample operation mode -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignHeifEncoder] :encoder Select encoder to use +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] # @!method heifsave_buffer(**opts) # Save image in heif format. # @param opts [Hash] Set of options # @option opts [Integer] :Q Q factor +# @option opts [Integer] :bitdepth Number of bits per pixel # @option opts [Boolean] :lossless Enable lossless compression # @option opts [Vips::ForeignHeifCompression] :compression Compression format # @option opts [Integer] :effort CPU effort # @option opts [Vips::ForeignSubsample] :subsample_mode Select chroma subsample operation mode -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignHeifEncoder] :encoder Select encoder to use +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [VipsBlob] Buffer to save to # @!method heifsave_target(target, **opts) @@ -2117,15 +2293,91 @@ class Image # @param target [Vips::Target] Target to save to # @param opts [Hash] Set of options # @option opts [Integer] :Q Q factor +# @option opts [Integer] :bitdepth Number of bits per pixel # @option opts [Boolean] :lossless Enable lossless compression # @option opts [Vips::ForeignHeifCompression] :compression Compression format # @option opts [Integer] :effort CPU effort # @option opts [Vips::ForeignSubsample] :subsample_mode Select chroma subsample operation mode -# @option opts [Boolean] :strip Strip all metadata from image +# @option opts [Vips::ForeignHeifEncoder] :encoder Select encoder to use +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain +# @option opts [Array] :background Background value +# @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed +# @return [nil] + +# @!method jxlsave(filename, **opts) +# Save image in jpeg-xl format. +# @param filename [String] Filename to save to +# @param opts [Hash] Set of options +# @option opts [Integer] :tier Decode speed tier +# @option opts [Float] :distance Target butteraugli distance +# @option opts [Integer] :effort Encoding effort +# @option opts [Boolean] :lossless Enable lossless compression +# @option opts [Integer] :Q Quality factor +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain +# @option opts [Array] :background Background value +# @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed +# @return [nil] + +# @!method jxlsave_buffer(**opts) +# Save image in jpeg-xl format. +# @param opts [Hash] Set of options +# @option opts [Integer] :tier Decode speed tier +# @option opts [Float] :distance Target butteraugli distance +# @option opts [Integer] :effort Encoding effort +# @option opts [Boolean] :lossless Enable lossless compression +# @option opts [Integer] :Q Quality factor +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain +# @option opts [Array] :background Background value +# @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed +# @return [VipsBlob] Buffer to save to + +# @!method jxlsave_target(target, **opts) +# Save image in jpeg-xl format. +# @param target [Vips::Target] Target to save to +# @param opts [Hash] Set of options +# @option opts [Integer] :tier Decode speed tier +# @option opts [Float] :distance Target butteraugli distance +# @option opts [Integer] :effort Encoding effort +# @option opts [Boolean] :lossless Enable lossless compression +# @option opts [Integer] :Q Quality factor +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain # @option opts [Array] :background Background value # @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed # @return [nil] +# @!method magicksave(filename, **opts) +# Save file with imagemagick. +# @param filename [String] Filename to save to +# @param opts [Hash] Set of options +# @option opts [String] :format Format to save in +# @option opts [Integer] :quality Quality to use +# @option opts [Boolean] :optimize_gif_frames Apply GIF frames optimization +# @option opts [Boolean] :optimize_gif_transparency Apply GIF transparency optimization +# @option opts [Integer] :bitdepth Number of bits per pixel +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain +# @option opts [Array] :background Background value +# @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed +# @return [nil] + +# @!method magicksave_buffer(**opts) +# Save image to magick buffer. +# @param opts [Hash] Set of options +# @option opts [String] :format Format to save in +# @option opts [Integer] :quality Quality to use +# @option opts [Boolean] :optimize_gif_frames Apply GIF frames optimization +# @option opts [Boolean] :optimize_gif_transparency Apply GIF transparency optimization +# @option opts [Integer] :bitdepth Number of bits per pixel +# @option opts [Vips::ForeignKeep] :keep Which metadata to retain +# @option opts [Array] :background Background value +# @option opts [Integer] :page_height Set page height for multipage save +# @option opts [String] :profile Filename of ICC profile to embed +# @return [VipsBlob] Buffer to save to + # @!method self.thumbnail(filename, width, **opts) # Generate thumbnail from file. # @param filename [String] Filename to read from @@ -2139,6 +2391,7 @@ class Image # @option opts [String] :import_profile Fallback import profile # @option opts [String] :export_profile Fallback export profile # @option opts [Vips::Intent] :intent Rendering intent +# @option opts [Vips::FailOn] :fail_on Error level to fail on # @return [Vips::Image] Output image # @!method self.thumbnail_buffer(buffer, width, **opts) @@ -2155,6 +2408,7 @@ class Image # @option opts [String] :import_profile Fallback import profile # @option opts [String] :export_profile Fallback export profile # @option opts [Vips::Intent] :intent Rendering intent +# @option opts [Vips::FailOn] :fail_on Error level to fail on # @return [Vips::Image] Output image # @!method thumbnail_image(width, **opts) @@ -2169,6 +2423,7 @@ class Image # @option opts [String] :import_profile Fallback import profile # @option opts [String] :export_profile Fallback export profile # @option opts [Vips::Intent] :intent Rendering intent +# @option opts [Vips::FailOn] :fail_on Error level to fail on # @return [Vips::Image] Output image # @!method self.thumbnail_source(source, width, **opts) @@ -2185,6 +2440,7 @@ class Image # @option opts [String] :import_profile Fallback import profile # @option opts [String] :export_profile Fallback export profile # @option opts [Vips::Intent] :intent Rendering intent +# @option opts [Vips::FailOn] :fail_on Error level to fail on # @return [Vips::Image] Output image # @!method mapim(index, **opts) @@ -2192,6 +2448,9 @@ class Image # @param index [Vips::Image] Index pixels with this # @param opts [Hash] Set of options # @option opts [Vips::Interpolate] :interpolate Interpolate pixels with this +# @option opts [Array] :background Background value +# @option opts [Boolean] :premultiplied Images have premultiplied alpha +# @option opts [Vips::Extend] :extend How to generate the extra pixels # @return [Vips::Image] Output image # @!method shrink(hshrink, vshrink, **opts) @@ -2199,18 +2458,21 @@ class Image # @param hshrink [Float] Horizontal shrink factor # @param vshrink [Float] Vertical shrink factor # @param opts [Hash] Set of options +# @option opts [Boolean] :ceil Round-up output dimensions # @return [Vips::Image] Output image # @!method shrinkh(hshrink, **opts) # Shrink an image horizontally. # @param hshrink [Integer] Horizontal shrink factor # @param opts [Hash] Set of options +# @option opts [Boolean] :ceil Round-up output dimensions # @return [Vips::Image] Output image # @!method shrinkv(vshrink, **opts) # Shrink an image vertically. # @param vshrink [Integer] Vertical shrink factor # @param opts [Hash] Set of options +# @option opts [Boolean] :ceil Round-up output dimensions # @return [Vips::Image] Output image # @!method reduceh(hshrink, **opts) @@ -2218,6 +2480,7 @@ class Image # @param hshrink [Float] Horizontal shrink factor # @param opts [Hash] Set of options # @option opts [Vips::Kernel] :kernel Resampling kernel +# @option opts [Float] :gap Reducing gap # @return [Vips::Image] Output image # @!method reducev(vshrink, **opts) @@ -2225,6 +2488,7 @@ class Image # @param vshrink [Float] Vertical shrink factor # @param opts [Hash] Set of options # @option opts [Vips::Kernel] :kernel Resampling kernel +# @option opts [Float] :gap Reducing gap # @return [Vips::Image] Output image # @!method reduce(hshrink, vshrink, **opts) @@ -2233,6 +2497,7 @@ class Image # @param vshrink [Float] Vertical shrink factor # @param opts [Hash] Set of options # @option opts [Vips::Kernel] :kernel Resampling kernel +# @option opts [Float] :gap Reducing gap # @return [Vips::Image] Output image # @!method quadratic(coeff, **opts) @@ -2261,7 +2526,7 @@ class Image # Similarity transform of an image. # @param opts [Hash] Set of options # @option opts [Float] :scale Scale by this factor -# @option opts [Float] :angle Rotate anticlockwise by this many degrees +# @option opts [Float] :angle Rotate clockwise by this many degrees # @option opts [Vips::Interpolate] :interpolate Interpolate pixels with this # @option opts [Array] :background Background value # @option opts [Float] :odx Horizontal output displacement @@ -2272,7 +2537,7 @@ class Image # @!method rotate(angle, **opts) # Rotate an image by a number of degrees. -# @param angle [Float] Rotate anticlockwise by this many degrees +# @param angle [Float] Rotate clockwise by this many degrees # @param opts [Hash] Set of options # @option opts [Vips::Interpolate] :interpolate Interpolate pixels with this # @option opts [Array] :background Background value @@ -2287,6 +2552,7 @@ class Image # @param scale [Float] Scale image by this factor # @param opts [Hash] Set of options # @option opts [Vips::Kernel] :kernel Resampling kernel +# @option opts [Float] :gap Reducing gap # @option opts [Float] :vscale Vertical scale image by this factor # @return [Vips::Image] Output image @@ -2339,16 +2605,6 @@ class Image # @param opts [Hash] Set of options # @return [Vips::Image] Output image -# @!method scRGB2XYZ(**opts) -# Transform scrgb to xyz. -# @param opts [Hash] Set of options -# @return [Vips::Image] Output image - -# @!method XYZ2scRGB(**opts) -# Transform xyz to scrgb. -# @param opts [Hash] Set of options -# @return [Vips::Image] Output image - # @!method LabQ2Lab(**opts) # Unpack a labq image to float lab. # @param opts [Hash] Set of options @@ -2459,12 +2715,22 @@ class Image # @param opts [Hash] Set of options # @return [Vips::Image] Output image +# @!method scRGB2XYZ(**opts) +# Transform scrgb to xyz. +# @param opts [Hash] Set of options +# @return [Vips::Image] Output image + # @!method scRGB2BW(**opts) # Convert scrgb to bw. # @param opts [Hash] Set of options # @option opts [Integer] :depth Output device space depth in bits # @return [Vips::Image] Output image +# @!method XYZ2scRGB(**opts) +# Transform xyz to scrgb. +# @param opts [Hash] Set of options +# @return [Vips::Image] Output image + # @!method scRGB2sRGB(**opts) # Convert an scrgb image to srgb. # @param opts [Hash] Set of options @@ -2491,7 +2757,7 @@ class Image # Map an image though a lut. # @param lut [Vips::Image] Look-up table image # @param opts [Hash] Set of options -# @option opts [Integer] :band apply one-band lut to this band of in +# @option opts [Integer] :band Apply one-band lut to this band of in # @return [Vips::Image] Output image # @!method case(cases, **opts) @@ -2604,7 +2870,7 @@ class Image # @return [Vips::Image] Output image # @!method convsep(mask, **opts) -# Seperable convolution operation. +# Separable convolution operation. # @param mask [Vips::Image] Input matrix image # @param opts [Hash] Set of options # @option opts [Vips::Precision] :precision Convolve with this precision @@ -2650,6 +2916,21 @@ class Image # @option opts [Vips::Precision] :precision Convolve with this precision # @return [Vips::Image] Output image +# @!method sobel(**opts) +# Sobel edge detector. +# @param opts [Hash] Set of options +# @return [Vips::Image] Output image + +# @!method scharr(**opts) +# Scharr edge detector. +# @param opts [Hash] Set of options +# @return [Vips::Image] Output image + +# @!method prewitt(**opts) +# Prewitt edge detector. +# @param opts [Hash] Set of options +# @return [Vips::Image] Output image + # @!method canny(**opts) # Canny edge detector. # @param opts [Hash] Set of options @@ -2657,11 +2938,6 @@ class Image # @option opts [Vips::Precision] :precision Convolve with this precision # @return [Vips::Image] Output image -# @!method sobel(**opts) -# Sobel edge detector. -# @param opts [Hash] Set of options -# @return [Vips::Image] Output image - # @!method fwfft(**opts) # Forward fft. # @param opts [Hash] Set of options @@ -2714,7 +2990,7 @@ class Image # @!method labelregions(**opts) # Label regions in an image. # @param opts [Hash] Set of options -# @option opts [Integer] :segments Output Number of discrete contigious regions +# @option opts [Integer] :segments Output Number of discrete contiguous regions # @return [Vips::Image, Hash Object>] Mask of region labels, Hash of optional output items # @!method fill_nearest(**opts) @@ -2772,9 +3048,9 @@ class Image # @option opts [Vips::Image] :test Test pixels in this image # @option opts [Boolean] :equal DrawFlood while equal to edge # @option opts [Integer] :left Output Left edge of modified area -# @option opts [Integer] :top Output top edge of modified area -# @option opts [Integer] :width Output width of modified area -# @option opts [Integer] :height Output height of modified area +# @option opts [Integer] :top Output Top edge of modified area +# @option opts [Integer] :width Output Width of modified area +# @option opts [Integer] :height Output Height of modified area # @return [Vips::Image, Hash Object>] Image to draw on, Hash of optional output items # @!method draw_image(sub, x, y, **opts) @@ -2844,7 +3120,6 @@ class Image # @option opts [Boolean] :search Search to improve tie-points # @option opts [Vips::Interpolate] :interpolate Interpolate pixels with this # @option opts [Integer] :mblend Maximum blend size -# @option opts [Integer] :bandno Band to search for features on # @return [Vips::Image] Output image # @!method matrixinvert(**opts) diff --git a/lib/vips/mutableimage.rb b/lib/vips/mutableimage.rb index 2290dba..75cc36a 100644 --- a/lib/vips/mutableimage.rb +++ b/lib/vips/mutableimage.rb @@ -58,7 +58,7 @@ def initialize(image) # See also the comment on set_type! before changing this. pointer = copy_image.ptr ::GObject.g_object_ref pointer - super pointer + super(pointer) # and save the copy ready for when we finish mutating @image = copy_image @@ -96,6 +96,13 @@ def method_missing name, *args, **options Vips::Operation.call name.to_s, [self, *args], options end + # Draw a point on an image. + # + # See {Image#draw_rect}. + def draw_point! ink, left, top, **opts + draw_rect! ink, left, top, 1, 1, **opts + end + # Create a metadata item on an image of the specifed type. Ruby types # are automatically transformed into the matching glib type (eg. # {GObject::GINT_TYPE}), if possible. diff --git a/lib/vips/object.rb b/lib/vips/object.rb index 3b3e92d..9541c6f 100644 --- a/lib/vips/object.rb +++ b/lib/vips/object.rb @@ -9,9 +9,6 @@ module Vips private - # debugging support - attach_function :vips_object_print_all, [], :void - # we must init these by hand, since they are usually made on first image # create attach_function :vips_band_format_get_type, [], :GType @@ -337,6 +334,7 @@ class ArgumentInstancePtr < FFI::Struct ArgumentClassPtr.ptr, ArgumentInstancePtr.ptr], :int + # debugging support attach_function :vips_object_print_all, [], :void attach_function :vips_object_set_from_string, [:pointer, :string], :int diff --git a/lib/vips/operation.rb b/lib/vips/operation.rb index 8fed370..7d58bc1 100644 --- a/lib/vips/operation.rb +++ b/lib/vips/operation.rb @@ -48,7 +48,8 @@ module Vips class Introspect attr_reader :name, :description, :flags, :args, :required_input, :optional_input, :required_output, :optional_output, :member_x, - :method_args, :vips_name, :destructive + :method_args, :vips_name, :destructive, :doc_optional_input, + :doc_optional_output @@introspect_cache = {} @@ -142,13 +143,15 @@ def add_yard_introspection name @flags = Vips.vips_operation_get_flags @op @member_x = nil @method_args = [] + @doc_optional_input = {} + @doc_optional_output = {} @args.each do |details| arg_name = details[:arg_name] flags = details[:flags] gtype = details[:gtype] - details[:yard_name] = arg_name == "in" ? "im" : arg_name + details[:yard_name] = (arg_name == "in") ? "im" : arg_name pspec = @op.get_pspec arg_name details[:blurb] = GObject.g_param_spec_get_blurb pspec @@ -164,6 +167,17 @@ def add_yard_introspection name end end end + + # and make the arg sets to document by filtering out deprecated args + @optional_input.each do |arg_name, details| + next if (details[:flags] & ARGUMENT_DEPRECATED) != 0 + @doc_optional_input[details[:arg_name]] = details + end + + @optional_output.each do |arg_name, details| + next if (details[:flags] & ARGUMENT_DEPRECATED) != 0 + @doc_optional_output[details[:arg_name]] = details + end end def self.get name @@ -204,7 +218,7 @@ def initialize value raise Vips::Error if value.null? end - super value + super end def build @@ -269,7 +283,7 @@ def set name, value, match_image, flags, gtype, destructive value = value.map { |x| Operation.imageize match_image, x } end - super name, value + super(name, value) end public @@ -426,14 +440,12 @@ def self.call name, supplied, optional = {}, option_string = "" end end - # collect a list of all input references here - references = Set.new + # dedupe all input references here + deduped_references = Set.new add_reference = lambda do |x| if x.is_a?(Vips::Image) - x.references.each do |i| - references << i - end + deduped_references.merge x.references end false end @@ -468,20 +480,27 @@ def self.call name, supplied, optional = {}, option_string = "" op = op.build + # we need an array of references for output objects + references = deduped_references.to_a + # attach all input refs to output x set_reference = lambda do |x| + # stop early if there are no refs to attach + return true if references == [] + if x.is_a? Vips::Image - x.references += references + references.each { |i| x.references << i } end + false end # get all required results result = [] required_output.each do |details| - value = details[:arg_name] + value = op.get(details[:arg_name]) flat_find value, &set_reference - result << op.get(value) + result << value end # fetch all optional ones diff --git a/lib/vips/region.rb b/lib/vips/region.rb index 92d08a0..31479db 100644 --- a/lib/vips/region.rb +++ b/lib/vips/region.rb @@ -44,10 +44,10 @@ class ManagedStruct < Vips::Object::ManagedStruct end def initialize(name) - ptr = Vips.vips_region_new name - raise Vips::Error if ptr.null? + pointer = Vips.vips_region_new name + raise Vips::Error if pointer.null? - super ptr + super(pointer) end def width diff --git a/lib/vips/sourcecustom.rb b/lib/vips/sourcecustom.rb index 48d5a05..9e1c5e7 100644 --- a/lib/vips/sourcecustom.rb +++ b/lib/vips/sourcecustom.rb @@ -47,7 +47,7 @@ def initialize pointer = Vips.vips_source_custom_new raise Vips::Error if pointer.null? - super pointer + super(pointer) end # The block is executed to read data from the source. The interface is diff --git a/lib/vips/targetcustom.rb b/lib/vips/targetcustom.rb index 9f07db7..2aa2575 100644 --- a/lib/vips/targetcustom.rb +++ b/lib/vips/targetcustom.rb @@ -47,7 +47,7 @@ def initialize pointer = Vips.vips_target_custom_new raise Vips::Error if pointer.null? - super pointer + super(pointer) end # The block is executed to write data to the source. The interface is diff --git a/lib/vips/version.rb b/lib/vips/version.rb index d1f9890..7e19f84 100644 --- a/lib/vips/version.rb +++ b/lib/vips/version.rb @@ -1,3 +1,3 @@ module Vips - VERSION = "2.1.4" + VERSION = "2.2.3" end diff --git a/ruby-vips.gemspec b/ruby-vips.gemspec index 9e70604..6f0ec85 100644 --- a/ruby-vips.gemspec +++ b/ruby-vips.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 2.0.0" spec.add_runtime_dependency "ffi", ["~> 1.12"] + spec.add_runtime_dependency "logger" spec.add_development_dependency "rake", ["~> 12.0"] spec.add_development_dependency "rspec", ["~> 3.3"] diff --git a/spec/block_operations_spec.rb b/spec/block_operations_spec.rb new file mode 100644 index 0000000..1ec4648 --- /dev/null +++ b/spec/block_operations_spec.rb @@ -0,0 +1,34 @@ +require "spec_helper" + +RSpec.describe Vips, version: [8, 13] do + let(:svg_image) { simg("lion.svg") } + let(:jpg_image) { simg("wagon.jpg") } + + if has_svg? + it "can block untrusted operations" do + untrusted_image = svg_image # svgload operation is known as untrusted + + # Block + Vips.block_untrusted(true) + expect { Vips::Image.new_from_file(untrusted_image) }.to raise_error Vips::Error, /not a known/ + + # Unblock + Vips.block_untrusted(false) + expect { Vips::Image.new_from_file(untrusted_image) }.not_to raise_error + end + end + + if has_jpeg? && has_svg? + it "can block specific operations" do + # Block all loaders except jpeg + Vips.block("VipsForeignLoad", true) + Vips.block("VipsForeignLoadJpeg", false) + expect { Vips::Image.new_from_file(svg_image) }.to raise_error Vips::Error, /not a known/ + expect { Vips::Image.new_from_file(jpg_image) }.not_to raise_error + + # Unblock all loaders + Vips.block("VipsForeignLoad", false) + expect { Vips::Image.new_from_file(svg_image) }.not_to raise_error + end + end +end diff --git a/spec/connection_spec.rb b/spec/connection_spec.rb index c2649e2..10dc4c7 100644 --- a/spec/connection_spec.rb +++ b/spec/connection_spec.rb @@ -20,7 +20,7 @@ end it "can create a source from an area of memory" do - str = File.open(simg("wagon.jpg"), "rb").read + str = File.binread(simg("wagon.jpg")) source = Vips::Source.new_from_memory str expect(source) @@ -140,21 +140,46 @@ expect(target) end +end + +# 8.13 had a broken on_finish, so close ourselves before 8.14 +RSpec.describe Vips::SourceCustom, version: [8, 9] do + it "can write an image to a user output stream with explicit close" do + image = Vips::Image.new_from_file simg("wagon.jpg") - it "can write an image to a user output stream" do filename = timg("x5.png") file = File.open filename, "wb" target = Vips::TargetCustom.new target.on_write { |chunk| file.write(chunk) } - target.on_finish { file.close } - image = Vips::Image.new_from_file simg("wagon.jpg") image.write_to_target target, ".png" + file.close - image = Vips::Image.new_from_file filename - expect(image) - expect(image.width).to eq(685) - expect(image.height).to eq(478) - expect(image.bands).to eq(3) - expect(image.avg).to be_within(0.001).of(109.789) + image2 = Vips::Image.new_from_file filename + expect(image2) + expect(image2.width).to eq(685) + expect(image2.height).to eq(478) + expect(image2.bands).to eq(3) + expect(image2.avg).to eq(image.avg) + end +end + +# on_finish started working again in 8.14 (and 8.13.4+, and 8.12 and earlier) +RSpec.describe Vips::SourceCustom, version: [8, 14] do + it "can write an image to a user output stream" do + image = Vips::Image.new_from_file simg("wagon.jpg") + + filename = timg("x5.png") + file = File.open filename, "wb" + target = Vips::TargetCustom.new + target.on_write { |chunk| file.write(chunk) } + target.on_finish { file.close } + image.write_to_target target, filename + + image2 = Vips::Image.new_from_file filename + expect(image2) + expect(image2.width).to eq(685) + expect(image2.height).to eq(478) + expect(image2.bands).to eq(3) + expect(image2.avg).to eq(image.avg) end end diff --git a/spec/image_spec.rb b/spec/image_spec.rb index f1d49f6..38fdb29 100644 --- a/spec/image_spec.rb +++ b/spec/image_spec.rb @@ -1,9 +1,5 @@ require "spec_helper" -def has_jpeg? - Vips.type_find("VipsOperation", "jpegload") != nil -end - RSpec.describe Vips::Image do it "can save an image to a file" do filename = timg "x.v" @@ -220,7 +216,7 @@ def has_jpeg? if has_jpeg? it "can load a sample jpg image buffer" do - str = File.open(simg("wagon.jpg"), "rb").read + str = File.binread(simg("wagon.jpg")) x = Vips::Image.new_from_buffer str, "" expect(x.width).to eq(685) expect(x.height).to eq(478) @@ -231,7 +227,7 @@ def has_jpeg? if has_jpeg? it "can load a sample jpg image utf-8 buffer" do - str = File.open(simg("wagon.jpg"), "r").read + str = File.read(simg("wagon.jpg")) x = Vips::Image.new_from_buffer str, "" expect(x.width).to eq(685) expect(x.height).to eq(478) @@ -257,7 +253,7 @@ def has_jpeg? if has_jpeg? it "can set an ICC profile on a jpg image" do x = Vips::Image.new_from_file simg("icc.jpg") - profile = File.open(simg("lcd.icc"), "rb").read + profile = File.binread(simg("lcd.icc")) x = x.copy x.set_value "icc-profile-data", profile x.write_to_file(timg("x.jpg")) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0410b1b..76227b0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,11 @@ +# Set default concurrency so we can check against it later. Must be set +# before Vips.init sets concurrency to the default. +DEFAULT_VIPS_CONCURRENCY = 5 +ENV["VIPS_CONCURRENCY"] = DEFAULT_VIPS_CONCURRENCY.to_s + +# Disable stderr output since we purposefully trigger warn-able behavior. +ENV["VIPS_WARNING"] = "1" + require "vips" require "tempfile" @@ -14,6 +22,14 @@ def timg(name) File.join(@temp_dir, name) end +def has_jpeg? + Vips.type_find("VipsOperation", "jpegload") != nil +end + +def has_svg? + Vips.type_find("VipsOperation", "svgload") != nil +end + RSpec.configure do |config| config.around do |example| Dir.mktmpdir("ruby-vips-spec-") do |dir| diff --git a/spec/vips_spec.rb b/spec/vips_spec.rb index 6f28cde..c569071 100644 --- a/spec/vips_spec.rb +++ b/spec/vips_spec.rb @@ -2,12 +2,43 @@ RSpec.describe Vips do describe "Vips" do + it "can get default concurrency" do + expect(Vips.concurrency_default).to eq DEFAULT_VIPS_CONCURRENCY + end + + it "can get concurrency" do + expect(Vips.concurrency).to eq Vips.concurrency_default + end + it "can set concurrency" do - Vips.concurrency_set 12 + expect(Vips.concurrency_set(12)).to eq 12 + expect(Vips.concurrency).to eq 12 + end + + it "clips concurrency to 1024" do + expect(Vips.concurrency_set(1025)).to eq 1024 + end + + it "can set concurrency to 0 to reset to default" do + Vips.concurrency_set(rand(100)) + expect(Vips.concurrency_set(0)).to eq Vips.concurrency_default + end + + it "can set concurrency to nil to reset to default" do + Vips.concurrency_set(rand(100)) + expect(Vips.concurrency_set(nil)).to eq Vips.concurrency_default end - it "can set SIMD" do - Vips.vector_set true + it "sets SIMD" do + default = Vips.vector? + + expect(Vips.vector_set(true)).to be true + expect(Vips.vector?).to be true + + expect(Vips.vector_set(false)).to be false + expect(Vips.vector?).to be false + + Vips.vector_set default end it "can enable leak testing" do @@ -15,24 +46,59 @@ Vips.leak_set false end - it "can set the operation cache size" do - Vips.cache_set_max 0 - Vips.cache_set_max 100 + it "can get a set of filename suffixes" do + suffs = Vips.get_suffixes + expect(suffs.length > 10).to be true unless suffs.empty? + end + end + + describe "cache" do + it "can get and set the operation cache size" do + default = Vips.cache_max + + expect(Vips.cache_set_max(0)).to be 0 + expect(Vips.cache_max).to be 0 + + expect(Vips.cache_set_max(default)).to be default + expect(Vips.cache_max).to be default end it "can set the operation cache memory limit" do - Vips.cache_set_max_mem 0 - Vips.cache_set_max_mem 10000000 + default = Vips.cache_max_mem + + expect(Vips.cache_set_max_mem(0)).to be 0 + expect(Vips.cache_max_mem).to be 0 + + expect(Vips.cache_set_max_mem(default)).to be default + expect(Vips.cache_max_mem).to be default end it "can set the operation cache file limit" do - Vips.cache_set_max_files 0 - Vips.cache_set_max_files 100 + default = Vips.cache_max_files + + expect(Vips.cache_set_max_files(0)).to be 0 + expect(Vips.cache_max_files).to be 0 + + expect(Vips.cache_set_max_files(default)).to be default + expect(Vips.cache_max_files).to be default end + end - it "can get a set of filename suffixes" do - suffs = Vips.get_suffixes - expect(suffs.length > 10).to be true unless suffs.empty? + describe "#tracked_*" do + it "can get allocated bytes" do + expect(Vips.tracked_mem).to be >= 0 + end + + it "can get allocated bytes high-water mark" do + expect(Vips.tracked_mem_highwater).to be >= 0 + end + + it "can get allocation count" do + expect(Vips.tracked_allocs).to be >= 0 + end + + it "can get open file count" do + expect(Vips.tracked_files).to be >= 0 end end