This library converts images to base64 encoding and vice versa.
Installation
pip install img64
Quick start
Convert Image to Base64
from PIL import Image
import cv2
import img64
# PIL image to Base64
image = Image.open('sample.png')
base64 = img64.image_to_base64(image)
base64[:30] # 'iVBORw0KGgoAAAANSUhEUgAABAAAAA...'
# Numpy(OpenCV) image to Base64
image = cv2.imread('sample.png')
image = cv2.cvtColor(image, cv2.COLOR_BGRA2RGBA)
base64 = img64.image_to_base64(image)
base64[:30] # 'iVBORw0KGgoAAAANSUhEUgAABAAAAA...'
Convert Base64 to Image
import img64
# Base64 to PIL image
base64 = 'iVBORw0KGgoAAAANSUhEUgAABAAAAA...'
image = img64.base64_to_image(base64, type='pil')
type(image) # PIL.Image.Image
# Base64 to Numpy(OpenCV) image
base64 = 'iVBORw0KGgoAAAANSUhEUgAABAAAAA...'
image = img64.base64_to_image(base64, type='numpy')
type(image) # numpy.ndarray
Information
- It was implemented by referencing ternaus/base64ToImageConverters.
- The referenced library doesn't ensure data consistency, but this library addresses that issue.
- This library enhances user convenience in handling both RGB and grayscale images.
Metadata
Release files for img64 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| img64-1.2.1.tar.gz | 3.7 kB | Without provenance | Details for img64-1.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| img64-1.2.1-py3-none-any.whl | Python 3 | none | any | Details for img64-1.2.1-py3-none-any.whl |
Total release size: 7.3 kB
Release files / img64-1.2.1.tar.gz
| Download URL | img64-1.2.1.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00eeca50f8a7b981021f00e3284e6df587baee8a2db5d2a030871e365bee879b
|
|
BLAKE2b-256 checksum How to use checksums |
d374cfbecb7d23044c22fd0951d2d0aa5c5a3d5448da605b88603c5fc8f76329
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.15
|
Release files / img64-1.2.1-py3-none-any.whl
| Download URL | img64-1.2.1-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
deeb93148d0032a4733284a38b89413a52df3bd34225af63c4ce26365e56966d
|
|
BLAKE2b-256 checksum How to use checksums |
3d6a58bd79f94e2fb6b560bb546e0340019ea0756589d466e953f32dccf1d95f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.15
|
Security for img64 1.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.