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

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)


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

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

  FileUtils.cp(download, file_path)
end