# iremover [![GitHub license](https://img.shields.io/github/license/pchchv/iremover.svg)](https://github.com/pchchv/iremover/blob/master/LICENSE) [![PyPi](https://img.shields.io/pypi/v/iremover?style=flat-square)](https://pypi.org/project/iremover/)
Image background remover
## Requirements
```
python: >3.7
```
## Installation
```bash
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 files
* ```iremover i path/to/input.png path/to/output.png```
- `p` for folders
* ```iremover p path/to/input path/to/output```
- `s` for http server
* ```curl -s "http://localhost:5000/?url=http://input.png" -o output.png```
A reference about the main team can be obtained by using:
```bash
iremover --help
```
And also about all the subcommands used:
```bash
iremover <COMMAND> --help
```
## Usage as a library
Input and output as bytes
```python
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
```python
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
```python
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
```python
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)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/pchchv/iremover",
"name": "iremover",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "remove,background",
"author": "Evgenii Pochechuev",
"author_email": "ipchchv@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/23/fd/13a8d862f1c0cfd47a4021bf3c406b5ca00cc249bcd42d64e9f0ac73f851/iremover-1.0.1.tar.gz",
"platform": null,
"description": "\n# iremover [![GitHub license](https://img.shields.io/github/license/pchchv/iremover.svg)](https://github.com/pchchv/iremover/blob/master/LICENSE) [![PyPi](https://img.shields.io/pypi/v/iremover?style=flat-square)](https://pypi.org/project/iremover/)\nImage background remover\n\n## Requirements \n\n```\npython: >3.7\n```\n\n## Installation\n\n```bash\npip install iremover\n```\n\n## Usage as a cli\n\nAfter installation, iiremover can be used simply by typing `iremover` in the terminal window.\n\nThe `iremover` command has 3 subcommands, one for each input type:\n- `i` for files \n * ```iremover i path/to/input.png path/to/output.png```\n- `p` for folders\n * ```iremover p path/to/input path/to/output```\n- `s` for http server\n * ```curl -s \"http://localhost:5000/?url=http://input.png\" -o output.png```\n\nA reference about the main team can be obtained by using:\n\n```bash\niremover --help\n```\n\nAnd also about all the subcommands used:\n\n```bash\niremover <COMMAND> --help\n```\n\n## Usage as a library\n\nInput and output as bytes\n\n```python\nfrom iremover import remove\n\ninput_path = 'input.png'\noutput_path = 'output.png'\n\nwith open(input_path, 'rb') as i:\n with open(output_path, 'wb') as o:\n input = i.read()\n output = remove(input)\n o.write(output)\n```\n\nInput and output as a PIL image\n\n```python\nfrom iremover import remove\nfrom PIL import Image\n\ninput_path = 'input.png'\noutput_path = 'output.png'\n\ninput = Image.open(input_path)\noutput = remove(input)\noutput.save(output_path)\n```\n\nInput and output as a numpy array\n\n```python\nfrom iremover import remove\nimport cv2\n\ninput_path = 'input.png'\noutput_path = 'output.png'\n\ninput = cv2.imread(input_path)\noutput = remove(input)\ncv2.imwrite(output_path, output)\n```\n\nHow to iterate over files in a performatic way\n\n```python\nfrom pathlib import Path\nfrom iremover import remove, new_session\n\nsession = new_session()\n\nfor file in Path('path/to/folder').glob('*.png'):\n input_path = str(file)\n output_path = str(file.parent / (file.stem + \".out.png\"))\n\n with open(input_path, 'rb') as i:\n with open(output_path, 'wb') as o:\n input = i.read()\n output = remove(input, session=session)\n o.write(output)\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0 license",
"summary": "Python 3 library. Image background remover.",
"version": "1.0.1",
"split_keywords": [
"remove",
"background"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "42bc90d12b97f5e0a0ec9fa04442b0e93235b388e44e1505737ed89322a5fdf0",
"md5": "34f64eb6c68de4cdaa1fb43454a8ddd8",
"sha256": "c121357806e3e8273d3646bd9ff54ed783bfee689c24a48261c09704ee58ce7d"
},
"downloads": -1,
"filename": "iremover-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "34f64eb6c68de4cdaa1fb43454a8ddd8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 15029,
"upload_time": "2023-03-24T10:34:09",
"upload_time_iso_8601": "2023-03-24T10:34:09.847160Z",
"url": "https://files.pythonhosted.org/packages/42/bc/90d12b97f5e0a0ec9fa04442b0e93235b388e44e1505737ed89322a5fdf0/iremover-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "23fd13a8d862f1c0cfd47a4021bf3c406b5ca00cc249bcd42d64e9f0ac73f851",
"md5": "2d01dc982f023026ec487dca70a898d0",
"sha256": "49f6a31e0eef230d55264b842305eb0d77ac820e870a61bb155f7217768c42b5"
},
"downloads": -1,
"filename": "iremover-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "2d01dc982f023026ec487dca70a898d0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 14487,
"upload_time": "2023-03-24T10:34:12",
"upload_time_iso_8601": "2023-03-24T10:34:12.567472Z",
"url": "https://files.pythonhosted.org/packages/23/fd/13a8d862f1c0cfd47a4021bf3c406b5ca00cc249bcd42d64e9f0ac73f851/iremover-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-24 10:34:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "pchchv",
"github_project": "iremover",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "iremover"
}