removebg

package module
v0.0.0-...-470bf6c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

README

removebg

A Golang API wrapper for removing background using remove.bg's API

License

This code is licensed under the GPL3 License. See here for more details.

Installation

go get github.com/g-lib/removebg@latest

Usage

RemoveFromFile

Removes the background given an image file.

Code Example:
import "github.com/g-lib/removebg"
rmbg = NewRemoveBg("YOUR-API-KEY")
rmbg.RemoveFromFile("test.jpg",nil)

RemoveBackgroundFromImgURL

Removes the background given an image URL.

Code Example:
import "github.com/g-lib/removebg"
rmbg = NewRemoveBg("YOUR-API-KEY")
rmbg.RemoveFromURL("http://www.example.com/some_image.jpg",nil)

RemoveBackgroundFromBase64Img

Removes the background given a base64 image string.

Code Example:
import "github.com/g-lib/removebg"
rmbg = NewRemoveBg("YOUR-API-KEY")
rmbg.RemoveFrombBase64("BASE64-CONTENT",nil)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIENDPOINT = "https://api.remove.bg/v1.0/removebg"

Functions

This section is empty.

Types

type RemoveBG

type RemoveBG struct {
	APIKey string
}

func NewRemoveBG

func NewRemoveBG(apiKey string) *RemoveBG

func (*RemoveBG) RemoveFromBase64

func (rb *RemoveBG) RemoveFromBase64(base64 string, opt *RemoveOption) error

func (*RemoveBG) RemoveFromFile

func (rb *RemoveBG) RemoveFromFile(filePath string, opt *RemoveOption) error

func (*RemoveBG) RemoveFromURL

func (rb *RemoveBG) RemoveFromURL(url string, opt *RemoveOption) error

type RemoveOption

type RemoveOption struct {
	// Size of the output image (`'auto'` = highest available resolution, `'preview'`|`'small'`|`'regular'` = 0.25 MP, `'medium'` = 1.5 MP, `'hd'` = 4 MP, `'full'`|`'4k'` = original size)
	Size string
	// Type foreground object (`'auto'` = autodetect, `'person'`, `'product'`, `'car'`)
	Type string
	// TypeLevel classification level of the foreground object (`'none'` = no classification, `'1'` = coarse classification (e.g. `'car'`), `'2'` = specific classification (e.g. `'car_interior'`), `'latest'` = latest classification)
	TypeLevel string
	// Format image format (`'auto'` = autodetect, `'png'`, `'jpg'`, `'zip'`)
	Format string
	// ROI region of interest, where to look for foreground object (x1, y1, x2, y2) in px or relative (%)
	ROI string
	// Crop px or relative, single val = all sides, two vals = top/bottom, left/right, four vals = top, right, bottom, left
	Crop string
	// Scale image scale relative to the total image size
	Scale string
	// Position `'center'`, `'original'`, single val = horizontal and vertical, two vals = horizontal, vertical
	Position string
	// Channels request the finalized image (`'rgba'`) or an alpha mask (`'alpha'`)
	Channels string
	// Shadow whether to add an artificial shadow (some types aren't supported)
	Shadow bool
	// Semitransparency  for windows or glass objects (some types aren't supported)
	Semitransparency bool
	// Background (`None` = no background, path, url, color hex code (e.g. `'81d4fa'`, `'fff'`), color name (e.g. `'green'`))
	Background string
	// Background type (`None` = no background, `'path'`, `'url'`, `'color'`)
	BackgroundType string
	NewFileName    string
}

func NewRemoveOption

func NewRemoveOption() *RemoveOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL