Class: RemoveBg::CompositeResult

Inherits:
Result
  • Object
show all
Defined in:
lib/remove_bg/composite_result.rb

Overview

Handles image composition for larger images (over 10MP) where transparency is required.

See Also:

Instance Attribute Summary

Attributes inherited from Result

#metadata, #rate_limit

Instance Method Summary collapse

Methods inherited from Result

#data, #initialize, #save, #save!

Constructor Details

This class inherits a constructor from RemoveBg::Result

Instance Method Details

#save_zip(file_path, overwrite: false) ⇒ nil

Saves the ZIP archive containing the alpha.png and color.jpg files (useful if you want to handle composition yourself)

Parameters:

  • file_path (string)
  • overwrite (boolean) (defaults to: false)

    Overwrite any existing file at the specified path

Returns:

  • (nil)

Raises:



17
18
19
20
21
22
23
# File 'lib/remove_bg/composite_result.rb', line 17

def save_zip(file_path, overwrite: false)
  raise FileOverwriteError.new(file_path) if File.exist?(file_path) && !overwrite

  warn("DEPRECATION WARNING: overwrite: true is deprecated and will be removed from remove_bg 2.0 (use save_zip! instead)") if overwrite

  FileUtils.cp(download, file_path)
end

#save_zip!(file_path) ⇒ nil

Saves the ZIP archive containing the alpha.png and color.jpg files, overwriting any exisiting files (useful if you want to handle composition yourself)

Parameters:

  • file_path (string)

Returns:

  • (nil)


30
31
32
# File 'lib/remove_bg/composite_result.rb', line 30

def save_zip!(file_path)
  FileUtils.cp(download, file_path)
end