https://github.com/waikato-datamining/simple-image-ops
Python3 library for resizing images either using OpenCV or Pillow.
https://github.com/waikato-datamining/simple-image-ops
image-processing opencv-python pillow python3
Last synced: 3 months ago
JSON representation
Python3 library for resizing images either using OpenCV or Pillow.
- Host: GitHub
- URL: https://github.com/waikato-datamining/simple-image-ops
- Owner: waikato-datamining
- License: apache-2.0
- Created: 2025-05-28T22:10:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-29T01:44:41.000Z (about 1 year ago)
- Last Synced: 2025-09-13T17:01:56.056Z (9 months ago)
- Topics: image-processing, opencv-python, pillow, python3
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.rst
- License: LICENSE
Awesome Lists containing this project
README
# simple-image-ops
Python3 library for simple image operations either using [OpenCV](https://github.com/opencv/opencv-python)
or [Pillow](https://github.com/python-pillow/Pillow).
## Installation
### PyPI
```bash
pip install simple_image_ops
```
### Github
```bash
pip install git+https://github.com/waikato-datamining/simple-image-ops.git
```
## API
The following I/O operations are available:
* `simops.load_file` - loads an image from disk
* `simops.load_bytes` - loads an image from a bytes structure
* `simops.save_file` - saves an image to disk
* `simops.save_bytes` - saves an images into a bytes structure
**NB:** the `save_` methods allow specifying the JPEG quality via the
`jpeg_quality` parameter.
The following image operations are available:
* `simops.flip` - flips the image left/right or top/bottom
* `simops.resize` - resizes the image
* `simops.rotate` - rotates the image by 90/180/270 degrees counter-clockwise
These helper methods are available:
* `simops.numpy_available` - whether Numpy is available
* `simops.opencv_available` - whether OpenCV is available
* `simops.pillow_available` - whether Pillow is available
## Examples
### Resize file
The following loads the images from disk, resizes it using explicit width/height,
and saves it back to disk:
```python
from simops import load_file, resize, save_file
img = load_file("input.jpg")
img_res = resize(img, width=800, height=600)
save_file(img_res, "output.jpg")
```
### Resize bytes
Here we load the image from bytes, resize it specifying only the width
(therefore keeping the aspect ratio) and then turn it back into bytes
(using JPEG format):
```python
from simops import load_bytes, resize, save_bytes
data_in = ... # obtained from somewhere
img = load_bytes(data_in)
img_res = resize(img, width=1024)
data_out = save_bytes(img_res, "JPEG")
```