Giter Site home page Giter Site logo

manu12121999 / removebg-gimp Goto Github PK

View Code? Open in Web Editor NEW
123.0 5.0 16.0 62 KB

A small GIMP plugin to easily remove the Background of an Image with remove.bg. Keeps the image size and the original Image

Python 100.00%
gimp removebg-gimp remove background remove-image-background

removebg-gimp's Introduction

RemoveBG-GIMP

This plugin automatically removes the image background using https://www.remove.bg/. The website uses neuronal networks to distinguish the foreground from the background. After that, a layer mask is applied to the image, which can be edited to improve the cut-out, if needed.

Usage

  1. Install the plugin as shown in the installation section
  2. Filters → removebackground
  3. Insert your RemoveBG API Key, which you can get from https://www.remove.bg/api 1

2

3

Installation

Windows:

  1. Put the remove_background.py file in your plugins directory:
  • C:\Program Files\GIMP 2\lib\gimp\2.0\plug-ins
  1. restart GIMP

Linux:

  1. Search your plugins directory. The directory might be at:

~/.gimp-2.10/plug-ins/

~/.config/GIMP/2.10/plug-ins

or /usr/lib/gimp/2.0/plug-ins

  1. Put remove_background.py in this directory and make it executable with chmod +x remove_background.py

  2. Make sure you have installed python support for gimp. (gimp-python package for ubuntu or python2-gimp from the AUR)

Problems:

  • If encountering any problems, try out the gimp2.0/requests branch, which uses more advanced libraries, although it takes extra steps to install.

Notes:

  • The plugin uploads the image to the website remove.bg. Don't use it for anything confidential!
  • Hard-code your key in the code for more convenience
  • This branch works only for GIMP up to version 2.10. For newer versions of GIMP (2.99 or 3.0), check out the branch "gimp3.0".

Licence:

It is not an official remove.bg plugin, so keep their Terms of Service in mind (https://www.remove.bg/tos)

Besides that, you can do whatever you want with my code!

removebg-gimp's People

Contributors

manu12121999 avatar matheusfillipe avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

removebg-gimp's Issues

NameError: global name 'requests' is not defined

Get the following error when running the plug in, any help please
System win10

Traceback (most recent call last):
File "C:\Program Files\GIMP 2\lib\gimp\2.0\python/gimpfu.py", line 741, in response
dialog.res = run_script(params)
File "C:\Program Files\GIMP 2\lib\gimp\2.0\python/gimpfu.py", line 362, in run_script
return apply(function, params)
File "C:\Users\Mo\AppData\Roaming\GIMP\2.10\plug-ins\remove_background.py", line 96, in remove_background
response = requests.post(
NameError: global name 'requests' is not defined

removebackground does not show up in the GIMP Menu

Hi,
I try to use this plugis in Debian Sid with Gimp 2.10.24. All dependencies is installed correctly as your instruction but the menu doesn't show up in filter menu.

Requirement already satisfied: requests in ./gimpenv/lib/python3.9/site-packages (2.26.0)
Requirement already satisfied: certifi>=2017.4.17 in ./gimpenv/lib/python3.9/site-packages (from requests) (2021.5.30)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./gimpenv/lib/python3.9/site-packages (from requests) (1.26.6)
Requirement already satisfied: idna<4,>=2.5 in ./gimpenv/lib/python3.9/site-packages (from requests) (3.2)
Requirement already satisfied: charset-normalizer~=2.0.0 in ./gimpenv/lib/python3.9/site-packages (from requests) (2.0.4)

[update]
here is what i get when i try to run Gimp via terminal:

$ gimp-2.10 
Traceback (most recent call last):
  File "/home/sherlock/.config/GIMP/2.10/plug-ins/remove_background.py", line 8, in <module>
    from gimpfu import *
ModuleNotFoundError: No module named 'gimpfu'
gimp-2.10: LibGimpBase-WARNING: gimp-2.10: gimp_wire_read(): error

Hope it helpful to trace the problem

error with python.exe get-pip.py

ERROR: Exception when installing RemoveBG-GIMP will not show up in GIMP 2.10.30

ERROR: Exception:
Traceback (most recent call last):
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_internal/cli/base_command.py", line 223, in _main
    status = self.run(options, args)
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_internal/cli/req_command.py", line 180, in wrapper
    return func(self, options, args)
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_internal/commands/install.py", line 404, in run
    pycompile=options.compile,
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_internal/req/__init__.py", line 90, in install_given_reqs
    pycompile=pycompile,
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_internal/req/req_install.py", line 824, in install
    requested=self.user_supplied,
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_internal/operations/install/wheel.py", line 845, in install_wheel
    requested=requested,
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_internal/operations/install/wheel.py", line 747, in _install_wheel
    generated_console_scripts = maker.make_multiple(scripts_to_generate)
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_vendor/distlib/scripts.py", line 418, in make_multiple
    filenames.extend(self.make(specification, options))
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_internal/operations/install/wheel.py", line 483, in make
    return super(PipScriptMaker, self).make(specification, options)
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_vendor/distlib/scripts.py", line 407, in make
    self._make_script(entry, filenames, options=options)
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_vendor/distlib/scripts.py", line 307, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_vendor/distlib/scripts.py", line 242, in _write_script
    launcher = self._get_launcher('t')
  File "c:/users/jlope/appdata/local/temp/tmpr_vc8b/pip.zip/pip/_vendor/distlib/scripts.py", line 386, in _get_launcher
    raise ValueError(msg)
ValueError: Unable to find resource t64.exe in package pip._vendor.distlib`
```

error with curl command

I get this error

Warning: Failed to create the file get-pip.py: Permission denied

curl: (23) Failure writing output to destination.

[Windows] Unable to Run

I'm receiving this error when trying to run the plug-in: RuntimeError: Could not open 'C:\tmp\temp.png' for writing: No such file or directory

Traceback More Information
Traceback (most recent call last):
File "C:\Program Files\GIMP 2\lib\gimp\2.0\python/gimpfu.py", line 740, in response
dialog.res = run_script(params)
File "C:\Program Files\GIMP 2\lib\gimp\2.0\python/gimpfu.py", line 361, in run_script
return apply(function, params)
File "C:\Program Files\GIMP 2\lib\gimp\2.0\plug-ins\remove_background.py", line 38, in remove_background
pdb.file_png_save_defaults(image, layer_copy, f, f)
RuntimeError: Could not open 'C:\tmp\temp.png' for writing: No such file or directory

Screenshot (115)_LI

Please consider configuring rembg for Gimp (it doesn't reduce quality and works 100% offline)

Many people who use Gimp on Linux do not like the concept of using a online tool that cannot be used locally offline, as they value privacy. You may not have known but https://github.com/danielgatis/rembg is a open source python neural network that works 100% offline and can be configured natively against ones system or a static miniconda environment profile. This allows the user to remove image backgrounds in high quality without sending their data to a foreign server.

please consider configuring rembg with Gimp. Below is a thread about it and some test I ran. I even made a bash script for myself to activate rembg from my start menu in a desired folder.

https://forums.linuxmint.com/viewtopic.php?f=42&t=339124

TEST
image

image

image

image

Could be corrupted in mandarin environment.

I faced a problem when I install into a mandarin windows 10 environment. That means, when I install windows 10 in Mandarin as primary language and define a mandarin username, I cannot use removebg-gimp. This is the error message.

Traceback (most recent call last):
File "C:\Program Files\GIMP 2\lib\gimp\2.0\python/gimpfu.py", line 741, in response
dialog.res = run_script(params)
File "C:\Program Files\GIMP 2\lib\gimp\2.0\python/gimpfu.py", line 362, in run_script
return apply(function, params)
File "C:\Program Files\GIMP 2\lib\gimp\2.0\plug-ins\remove_background.py", line 44, in remove_background
pdb.file_png_save_defaults(image, layer_copy, f, f)
RuntimeError: 無法開啟‘c:\users\�^�߫�\appdata\local\temp\temp.png’來寫入資料:Invalid argument

remark 無法開啟=cannot open
remark 來寫入資料=to write data (into the following location)

程序「file-png-save-defaults」的呼叫錯誤:

無法開啟‘c:\users\�^�߫�\appdata\local\temp\temp.png’來寫入資料:Invalid argument

remark 程序=programme
remark 的呼叫錯誤= something's calling failure

Plug-in 'removebackground' left image undo in inconsistent state, closing open undo groups.

ValueError: Unable to find resource t64.exe in package pip._vendor.distlib

Hi.
I tried removebg-gimp, but the filter does not show up in the menu after restarting gimp.
I tried removebg-gimp-requests, but that is throwing ValueError: Unable to find resource t64.exe in package pip._vendor.distlib

`
C:\Windows\System32>cd "C:\Program Files\GIMP 2\bin"

C:\Program Files\GIMP 2\bin>curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1863k 100 1863k 0 0 7335k 0 --:--:-- --:--:-- --:--:-- 7365k

C:\Program Files\GIMP 2\bin>python.exe get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pip<21.0
Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
|################################| 1.5 MB 4.2 MB/s
Collecting wheel
Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, wheel
Attempting uninstall: pip
Found existing installation: pip 20.0.2
Uninstalling pip-20.0.2:
Successfully uninstalled pip-20.0.2
Rolling back uninstall of pip
Moving to c:\program files\gimp 2\lib\python2.7\site-packages\pip
from c:\program files\gimp 2\lib\python2.7\site-packages~ip
Moving to c:\program files\gimp 2\lib\python2.7\site-packages\pip-20.0.2-py2.7.egg-info
from c:\program files\gimp 2\lib\python2.7\site-packages~ip-20.0.2-py2.7.egg-info
ERROR: Exception:
Traceback (most recent call last):
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_internal/cli/base_command.py", line 223, in _main
status = self.run(options, args)
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_internal/cli/req_command.py", line 180, in wrapper
return func(self, options, args)
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_internal/commands/install.py", line 404, in run
pycompile=options.compile,
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_internal/req/init.py", line 90, in install_given_reqs
pycompile=pycompile,
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_internal/req/req_install.py", line 824, in install
requested=self.user_supplied,
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_internal/operations/install/wheel.py", line 845, in install_wheel
requested=requested,
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_internal/operations/install/wheel.py", line 747, in _install_wheel
generated_console_scripts = maker.make_multiple(scripts_to_generate)
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_vendor/distlib/scripts.py", line 418, in make_multiple
filenames.extend(self.make(specification, options))
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_internal/operations/install/wheel.py", line 483, in make
return super(PipScriptMaker, self).make(specification, options)
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_vendor/distlib/scripts.py", line 407, in make
self._make_script(entry, filenames, options=options)
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_vendor/distlib/scripts.py", line 307, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_vendor/distlib/scripts.py", line 242, in _write_script
launcher = self._get_launcher('t')
File "c:/users/user1/appdata/local/temp/tmppcsoks/pip.zip/pip/_vendor/distlib/scripts.py", line 386, in _get_launcher
raise ValueError(msg)
ValueError: Unable to find resource t64.exe in package pip._vendor.distlib

C:\Program Files\GIMP 2\bin>python.exe -m pip install requests
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Requirement already satisfied: requests in c:\program files\gimp 2\lib\python2.7\site-packages (2.22.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\program files\gimp 2\lib\python2.7\site-packages (from requests) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in c:\program files\gimp 2\lib\python2.7\site-packages (from requests) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\program files\gimp 2\lib\python2.7\site-packages (from requests) (1.25.6)
Requirement already satisfied: certifi>=2017.4.17 in c:\program files\gimp 2\lib\python2.7\site-packages (from requests) (2019.9.11)

C:\Program Files\GIMP 2\bin>

`

wont show

on arch with gimp python and requests installed. pip install requests returns this
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: requests in /usr/lib/python3.8/site-packages (2.24.0)
Requirement already satisfied: chardet>=3.0.2 in /usr/lib/python3.8/site-packages (from requests) (3.0.4)
Requirement already satisfied: idna>=2.5 in /usr/lib/python3.8/site-packages (from requests) (2.10)
Requirement already satisfied: urllib3>=1.21.1 in /usr/lib/python3.8/site-packages (from requests) (1.25.9)
it doesnt show up in the filters menu

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.