Python 3 library. Image background remover.
Project description
iremover
Image background remover
Requirements
python: >3.7
Installation
pip install iremover
Usage as a cli
After installation, iiremover can be used simply by typing iremover
in the terminal window.
The iremover
command has 3 subcommands, one for each input type:
i
for filesiremover i path/to/input.png path/to/output.png
p
for foldersiremover p path/to/input path/to/output
s
for http servercurl -s "http://localhost:5000/?url=http://input.png" -o output.png
A reference about the main team can be obtained by using:
iremover --help
And also about all the subcommands used:
iremover <COMMAND> --help
Usage as a library
Input and output as bytes
from iremover import remove
input_path = 'input.png'
output_path = 'output.png'
with open(input_path, 'rb') as i:
with open(output_path, 'wb') as o:
input = i.read()
output = remove(input)
o.write(output)
Input and output as a PIL image
from iremover import remove
from PIL import Image
input_path = 'input.png'
output_path = 'output.png'
input = Image.open(input_path)
output = remove(input)
output.save(output_path)
Input and output as a numpy array
from iremover import remove
import cv2
input_path = 'input.png'
output_path = 'output.png'
input = cv2.imread(input_path)
output = remove(input)
cv2.imwrite(output_path, output)
How to iterate over files in a performatic way
from pathlib import Path
from iremover import remove, new_session
session = new_session()
for file in Path('path/to/folder').glob('*.png'):
input_path = str(file)
output_path = str(file.parent / (file.stem + ".out.png"))
with open(input_path, 'rb') as i:
with open(output_path, 'wb') as o:
input = i.read()
output = remove(input, session=session)
o.write(output)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
iremover-1.0.0.tar.gz
(14.4 kB
view details)
Built Distribution
iremover-1.0.0-py3-none-any.whl
(14.9 kB
view details)
File details
Details for the file iremover-1.0.0.tar.gz
.
File metadata
- Download URL: iremover-1.0.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 293b23d1d45338663c1069871f49f6a0f2d08c57d854ba6331fda9ae75fea19e |
|
MD5 | ada5d3b98b5e90505702836cf1e98ecd |
|
BLAKE2b-256 | 0a3cd8b7b70dfe279cc99fd46d0e21b2a697df18d9ce628cd69e8690b8d6c175 |
File details
Details for the file iremover-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: iremover-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21fcd4b541720eedda7dba1162553e02790e4e402f5bf3ccb353d08054d1f616 |
|
MD5 | fb694725f2d5016ed5fde0f77dba5ea9 |
|
BLAKE2b-256 | b4ab7a423db6ea6028121ce3a6c9863a538b5447becbd5b0b06f21c420cab6dc |