lib/vips/image.rb in vips-8.8.0.1 vs lib/vips/image.rb in vips-8.8.0.2

- old
+ new

@@ -250,11 +250,11 @@ # @option opts [Vips::Access] :access (:random) Access mode for file # # @param name [String] the filename to load from # @macro vips.loadopts # @return [Image] the loaded image - def self.new_from_file name, opts = {} + def self.new_from_file name, **opts # very common, and Vips::vips_filename_get_filename will segv if we # pass this raise Vips::Error, "filename is nil" if name == nil filename = Vips::p2str(Vips::vips_filename_get_filename name) @@ -294,11 +294,11 @@ # # @param data [String] the data to load from # @param option_string [String] load options as a string # @macro vips.loadopts # @return [Image] the loaded image - def self.new_from_buffer data, option_string, opts = {} + def self.new_from_buffer data, option_string, **opts loader = Vips::vips_foreign_find_load_buffer data, data.bytesize raise Vips::Error if loader == nil Vips::Operation.call loader, [data], opts, option_string end @@ -416,11 +416,11 @@ # @option opts [Boolean] :strip (false) Strip all metadata from image # @option opts [Array<Float>] :background (0) Background colour to # flatten alpha against, if necessary # # @param name [String] filename to write to - def write_to_file name, opts = {} + def write_to_file name, **opts filename = Vips::p2str(Vips::vips_filename_get_filename name) option_string = Vips::p2str(Vips::vips_filename_get_options name) saver = Vips::vips_foreign_find_save filename if saver == nil raise Vips::Error, "No known saver for '#{filename}'." @@ -454,11 +454,11 @@ # to see all the available options for JPEG save. # # @param format_string [String] save format plus options # @macro vips.saveopts # @return [String] the image saved in the specified format - def write_to_buffer format_string, opts = {} + def write_to_buffer format_string, **opts filename = Vips::p2str(Vips::vips_filename_get_filename format_string) option_string = Vips::p2str(Vips::vips_filename_get_options format_string) saver = Vips::vips_foreign_find_save_buffer filename @@ -751,11 +751,11 @@ # Draw a point on an image. # # See {Image#draw_rect}. # # @return [Image] modified image - def draw_point ink, left, top, opts = {} + def draw_point ink, left, top, **opts draw_rect ink, left, top, 1, 1, opts end # Add an image, constant or array. # @@ -1059,11 +1059,11 @@ # @param mode [BlendMode, Array<BlendMode>] blend modes to use # @param opts [Hash] Set of options # @option opts [Vips::Interpretation] :compositing_space Composite images in this colour space # @option opts [Boolean] :premultiplied Images have premultiplied alpha # @return [Image] blended image - def composite overlay, mode, opts = {} + def composite overlay, mode, **opts unless overlay.is_a? Array overlay = [overlay] end unless mode.is_a? Array mode = [mode] @@ -1302,11 +1302,11 @@ # @param th [Image, Real, Array<Real>] true values # @param el [Image, Real, Array<Real>] false values # @param opts [Hash] set of options # @option opts [Boolean] :blend (false) Blend smoothly between th and el # @return [Image] merged image - def ifthenelse(th, el, opts = {}) + def ifthenelse(th, el, **opts) match_image = [th, el, self].find {|x| x.is_a? Vips::Image} unless th.is_a? Vips::Image th = Operation.imageize match_image, th end @@ -1320,11 +1320,11 @@ # Scale an image to uchar. This is the vips `scale` operation, but # renamed to avoid a clash with the `.scale` property. # # @param opts [Hash] Set of options # @return [Vips::Image] Output image - def scaleimage opts = {} + def scaleimage **opts Vips::Image.scale self, opts end end end @@ -1428,10 +1428,10 @@ print "# @!method " print "self." unless member_x print "#{nickname}(" print required_input.map{|x| x[:name]}.join(", ") print ", " if required_input.length > 0 - puts "opts = {})" + puts "**opts)" puts "# #{description.capitalize}." required_input.each do |arg| puts "# @param #{arg[:name]} [#{arg[:type_name]}] " +