Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ternaus/base64toimageconverters
Library for converting from RGB / GrayScale image to base64 and back.
https://github.com/ternaus/base64toimageconverters
base64-decoding base64-encoding base64-image base64image image-processing image2base64 jpeg python
Last synced: 19 days ago
JSON representation
Library for converting from RGB / GrayScale image to base64 and back.
- Host: GitHub
- URL: https://github.com/ternaus/base64toimageconverters
- Owner: ternaus
- License: apache-2.0
- Created: 2022-04-07T18:41:23.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-19T21:34:01.000Z (over 2 years ago)
- Last Synced: 2024-12-29T00:34:34.463Z (28 days ago)
- Topics: base64-decoding, base64-encoding, base64-image, base64image, image-processing, image2base64, jpeg, python
- Language: Python
- Homepage:
- Size: 24.4 KB
- Stars: 19
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Library for converting RGB / Grayscale numpy images from to base64 and back.
## Installation
```bash
pip install -U image_to_base_64
```## Conversion
Takes `numpy.array` or `PIL.Image` as input### RGB to base 64
```python
base64 = rgb2base64(rgb_image, image_format)
```
where image format is `JPEG`, `PNG`### Grayscale to base 64
```python
base64 = grayscale2base64(grayscale_image)
```### Base64 to RGB image
```python
output_type = "cv2" # or "PIL"
rgb_image = base64_to_rgb(base64, output_type)
```### Base64 to Grayscale image
```python
output_type = "cv2" # or "PIL"
grayscale_image = base64_to_grayscale(base64, output_type)
```#### Issues
For some reason I cannot convert `RGB` image to `JPEG` representation in base 64 and back without losses.
=> test only for `PNG` and not `JPEG`