This library is a tool for converting images to base64 encoding and vice versa.
Project description
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
img64-1.2.1.tar.gz
(3.7 kB
view details)
Built Distribution
img64-1.2.1-py3-none-any.whl
(3.6 kB
view details)
File details
Details for the file img64-1.2.1.tar.gz
.
File metadata
- Download URL: img64-1.2.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00eeca50f8a7b981021f00e3284e6df587baee8a2db5d2a030871e365bee879b |
|
MD5 | 9bd3c313b425c15859fd569b364d4cd2 |
|
BLAKE2b-256 | d374cfbecb7d23044c22fd0951d2d0aa5c5a3d5448da605b88603c5fc8f76329 |
File details
Details for the file img64-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: img64-1.2.1-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | deeb93148d0032a4733284a38b89413a52df3bd34225af63c4ce26365e56966d |
|
MD5 | 26fb72e6fa8a47d3da4cc61bf7ec5efc |
|
BLAKE2b-256 | 3d6a58bd79f94e2fb6b560bb546e0340019ea0756589d466e953f32dccf1d95f |