Code Monkey home page Code Monkey logo

remove-bg's Introduction

remove.bg logo

Remove-Bg

A simple python (scraper) tool for remove background on image

This tool is scraper tool for https://www.remove.bg

Required module

  • requests

pip install requests

Function

Remove-Bg has only one function named 'removeBg' with required paramenter 'file_source'

and one optional paramenter 'delay' with default value is 1

Usage

In the remove-bg directory, you can import it as a module or use it directly and give you result as json

- As module

Example:

from removebg import removeBg

image_file = "https://i.redd.it/oxjnv3nybnx71.jpg"
result = removeBg(image_file)
print(result)

Output:

$ {'original': {'url': 'https://o.remove.bg/uploads/8fc6f083-ebd6-495a-b363-a629c0a5ab32/oxjnv3nybnx71.jpg'}, 'result': {'url': 'https://o.remove.bg/downloads/8fc6f083-ebd6-495a-b363-a629c0a5ab32/oxjnv3nybnx71-removebg-preview.png', 'width': 472, 'height': 529, 'rated': False, 'filename': 'oxjnv3nybnx71-removebg-preview.png', 'foreground_type': 'person'}, 'full': {'width': 680, 'height': 763, 'url': '/images/8fc6f083-ebd6-495a-b363-a629c0a5ab32/full_image'}}

- Use directly

$ python removebg.py

Output:

$ input image file source: https://i.redd.it/oxjnv3nybnx71.jpg
{'original': {'url': 'https://o.remove.bg/uploads/8fc6f083-ebd6-495a-b363-a629c0a5ab32/oxjnv3nybnx71.jpg'}, 'result': {'url': 'https://o.remove.bg/downloads/8fc6f083-ebd6-495a-b363-a629c0a5ab32/oxjnv3nybnx71-removebg-preview.png', 'width': 472, 'height': 529, 'rated': False, 'filename': 'oxjnv3nybnx71-removebg-preview.png', 'foreground_type': 'person'}, 'full': {'width': 680, 'height': 763, 'url': '/images/8fc6f083-ebd6-495a-b363-a629c0a5ab32/full_image'}}

- With CLI

$ python cli.py -h

The usage:

usage: cli.py [-h] --input INPUT [--dir DIR] [--output OUTPUT] [--download]

Remove-Bg

options:
  -h, --help            show this help message and exit
  --input INPUT, -i INPUT
                        Specify the input image file
  --dir DIR             Specify the output directory
  --output OUTPUT, -o OUTPUT
                        Specify the output filename
  --download, -d        Download the processed file

Example usage:

python cli.py --input myfile.jpg --dir Pictures --output mytransparentfile.png --download

The command above will send your input image and download the result to Pictures directory, with a new name mytransparentfile.png

Image result

From this

chad image

To this

chad image

As a suggestion, use an online host like flask in heroku to avoid captcha blocking although that will still happen.

Please contribute so that this scraper can be better

I hope it's useful for you

Thanks

remove-bg's People

Contributors

karjok avatar mochidaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

mochidaz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.