



<p align="center">
<img src="https://github.com/gibiee/img64/assets/37574274/1e4ba6f4-776d-4e84-b589-09f75d64d175" width="50%" height="50%" />
</p>
This library converts images to base64 encoding and vice versa.
# Installation
```sh
pip install img64
```
# Quick start
## Convert Image to Base64
```py
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
```py
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](https://github.com/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.
Raw data
{
"_id": null,
"home_page": "https://github.com/gibiee/img64",
"name": "img64",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": null,
"keywords": "image, base64, image_base64",
"author": "gibiee",
"author_email": "gibiee@naver.com",
"download_url": "https://files.pythonhosted.org/packages/d3/74/cfbecb7d23044c22fd0951d2d0aa5c5a3d5448da605b88603c5fc8f76329/img64-1.2.1.tar.gz",
"platform": null,
"description": "\n\n\n\n\n<p align=\"center\">\n <img src=\"https://github.com/gibiee/img64/assets/37574274/1e4ba6f4-776d-4e84-b589-09f75d64d175\" width=\"50%\" height=\"50%\" />\n</p>\n\nThis library converts images to base64 encoding and vice versa.\n\n\n# Installation\n```sh\npip install img64\n```\n\n\n# Quick start\n\n## Convert Image to Base64\n```py\nfrom PIL import Image\nimport cv2\nimport img64\n\n# PIL image to Base64\nimage = Image.open('sample.png')\nbase64 = img64.image_to_base64(image)\nbase64[:30] # 'iVBORw0KGgoAAAANSUhEUgAABAAAAA...'\n\n# Numpy(OpenCV) image to Base64\nimage = cv2.imread('sample.png')\nimage = cv2.cvtColor(image, cv2.COLOR_BGRA2RGBA)\nbase64 = img64.image_to_base64(image)\nbase64[:30] # 'iVBORw0KGgoAAAANSUhEUgAABAAAAA...'\n```\n\n## Convert Base64 to Image\n```py\nimport img64\n\n# Base64 to PIL image\nbase64 = 'iVBORw0KGgoAAAANSUhEUgAABAAAAA...'\nimage = img64.base64_to_image(base64, type='pil')\ntype(image) # PIL.Image.Image\n\n# Base64 to Numpy(OpenCV) image\nbase64 = 'iVBORw0KGgoAAAANSUhEUgAABAAAAA...'\nimage = img64.base64_to_image(base64, type='numpy')\ntype(image) # numpy.ndarray\n```\n\n# Information\n- It was implemented by referencing [ternaus/base64ToImageConverters](https://github.com/ternaus/base64ToImageConverters).\n - The referenced library doesn't ensure data consistency, but this library addresses that issue.\n - This library enhances user convenience in handling both RGB and grayscale images.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "This library is a tool for converting images to base64 encoding and vice versa.",
"version": "1.2.1",
"project_urls": {
"Homepage": "https://github.com/gibiee/img64"
},
"split_keywords": [
"image",
" base64",
" image_base64"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3d6a58bd79f94e2fb6b560bb546e0340019ea0756589d466e953f32dccf1d95f",
"md5": "26fb72e6fa8a47d3da4cc61bf7ec5efc",
"sha256": "deeb93148d0032a4733284a38b89413a52df3bd34225af63c4ce26365e56966d"
},
"downloads": -1,
"filename": "img64-1.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "26fb72e6fa8a47d3da4cc61bf7ec5efc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3",
"size": 3604,
"upload_time": "2024-11-14T07:13:35",
"upload_time_iso_8601": "2024-11-14T07:13:35.351238Z",
"url": "https://files.pythonhosted.org/packages/3d/6a/58bd79f94e2fb6b560bb546e0340019ea0756589d466e953f32dccf1d95f/img64-1.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d374cfbecb7d23044c22fd0951d2d0aa5c5a3d5448da605b88603c5fc8f76329",
"md5": "9bd3c313b425c15859fd569b364d4cd2",
"sha256": "00eeca50f8a7b981021f00e3284e6df587baee8a2db5d2a030871e365bee879b"
},
"downloads": -1,
"filename": "img64-1.2.1.tar.gz",
"has_sig": false,
"md5_digest": "9bd3c313b425c15859fd569b364d4cd2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 3674,
"upload_time": "2024-11-14T07:13:37",
"upload_time_iso_8601": "2024-11-14T07:13:37.010823Z",
"url": "https://files.pythonhosted.org/packages/d3/74/cfbecb7d23044c22fd0951d2d0aa5c5a3d5448da605b88603c5fc8f76329/img64-1.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-14 07:13:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gibiee",
"github_project": "img64",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "img64"
}