Module: RemoveBg

Defined in:
lib/remove_bg.rb,
lib/remove_bg/api.rb,
lib/remove_bg/error.rb,
lib/remove_bg/result.rb,
lib/remove_bg/upload.rb,
lib/remove_bg/version.rb,
lib/remove_bg/api_client.rb,
lib/remove_bg/account_info.rb,
lib/remove_bg/configuration.rb,
lib/remove_bg/url_validator.rb,
lib/remove_bg/image_composer.rb,
lib/remove_bg/http_connection.rb,
lib/remove_bg/rate_limit_info.rb,
lib/remove_bg/request_options.rb,
lib/remove_bg/result_metadata.rb,
lib/remove_bg/composite_result.rb,
lib/remove_bg/base_request_options.rb

Defined Under Namespace

Modules: Api Classes: AccountInfo, ApiClient, BaseRequestOptions, ClientHttpError, CompositeResult, Configuration, Error, FileError, FileMissingError, FileOverwriteError, HttpConnection, HttpError, ImageComposer, InvalidUrlError, RateLimitError, RateLimitInfo, RequestOptions, Result, ResultMetadata, ServerHttpError, Upload, UrlValidator

Constant Summary collapse

VERSION =
"1.5.0"

Class Method Summary collapse

Class Method Details

.account_info(raw_options = {}) ⇒ RemoveBg::AccountInfo

Fetches account information for the globally configured API key, or a specific API key if provided

Parameters:

  • options (Hash<Symbol, Object>)

Returns:



32
33
34
35
# File 'lib/remove_bg.rb', line 32

def self.(raw_options = {})
  options = RemoveBg::BaseRequestOptions.new(raw_options)
  ApiClient.new.(options)
end

.configure {|RemoveBg::Configuration| ... } ⇒ Object

Yields the global Remove.bg configuration



39
40
41
# File 'lib/remove_bg.rb', line 39

def self.configure
  yield RemoveBg::Configuration.configuration
end

.from_file(image_path, raw_options = {}) ⇒ RemoveBg::Result|RemoveBg::CompositeResult

Removes the background from an image on the local file system

Parameters:

  • image_path (String)

    Path to the input image

  • options (Hash<Symbol, Object>)

    Image processing options (see API docs)

Returns:



12
13
14
15
# File 'lib/remove_bg.rb', line 12

def self.from_file(image_path, raw_options = {})
  options = RemoveBg::RequestOptions.new(raw_options)
  ApiClient.new.remove_from_file(image_path, options)
end

.from_url(image_url, raw_options = {}) ⇒ RemoveBg::Result|RemoveBg::CompositeResult

Removes the background from the image at the URL specified

Parameters:

  • image_url (String)

    Absolute URL of the input image

  • options (Hash<Symbol, Object>)

    Image processing options (see API docs)

Returns:



22
23
24
25
# File 'lib/remove_bg.rb', line 22

def self.from_url(image_url, raw_options = {})
  options = RemoveBg::RequestOptions.new(raw_options)
  ApiClient.new.remove_from_url(image_url, options)
end