Skip to main content

PyPI - Version PyPI - Downloads PyPI - License PyPI - Python Version

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)

Source distribution for img64 1.2.1
File Size Uploaded
img64-1.2.1.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for img64 1.2.1
File Interpreter ABI Platform
img64-1.2.1-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page