img64


Nameimg64 JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/gibiee/img64
SummaryThis library is a tool for converting images to base64 encoding and vice versa.
upload_time2024-04-13 07:37:51
maintainerNone
docs_urlNone
authorgibiee
requires_python>=3
licenseMIT
keywords image base64 image_base64
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![PyPI - Version](https://img.shields.io/pypi/v/img64)
![PyPI - Downloads](https://img.shields.io/pypi/dm/img64?color=red)
![PyPI - License](https://img.shields.io/pypi/l/img64)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/img64)

<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, so 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/f8/0c/82e02c9dcbdf9142d27e18ea58113fabdd9fa39590aa8c0cbb15a69cb35b/img64-1.1.0.tar.gz",
    "platform": null,
    "description": "![PyPI - Version](https://img.shields.io/pypi/v/img64)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/img64?color=red)\n![PyPI - License](https://img.shields.io/pypi/l/img64)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/img64)\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, so 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.1.0",
    "project_urls": {
        "Homepage": "https://github.com/gibiee/img64"
    },
    "split_keywords": [
        "image",
        " base64",
        " image_base64"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "69498460e39e242f2acecd89c33cbdd9fbddf714438b3dd9d36383061a9c5ff5",
                "md5": "7d60598ced4aab22b453818b477b38f2",
                "sha256": "0bb0caeeb7d12d9f652ef864eb2199c5fac5d2cf24dbf886d54975200ce091a0"
            },
            "downloads": -1,
            "filename": "img64-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7d60598ced4aab22b453818b477b38f2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 3500,
            "upload_time": "2024-04-13T07:37:50",
            "upload_time_iso_8601": "2024-04-13T07:37:50.424379Z",
            "url": "https://files.pythonhosted.org/packages/69/49/8460e39e242f2acecd89c33cbdd9fbddf714438b3dd9d36383061a9c5ff5/img64-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f80c82e02c9dcbdf9142d27e18ea58113fabdd9fa39590aa8c0cbb15a69cb35b",
                "md5": "417fa038ab4124c45186f1132000fe25",
                "sha256": "b1e41a5f0b61e5407e2d335f951a9ca83e0f39979625e4c53ce20862a0104a90"
            },
            "downloads": -1,
            "filename": "img64-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "417fa038ab4124c45186f1132000fe25",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 3414,
            "upload_time": "2024-04-13T07:37:51",
            "upload_time_iso_8601": "2024-04-13T07:37:51.540559Z",
            "url": "https://files.pythonhosted.org/packages/f8/0c/82e02c9dcbdf9142d27e18ea58113fabdd9fa39590aa8c0cbb15a69cb35b/img64-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-13 07:37:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gibiee",
    "github_project": "img64",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "img64"
}
        
Elapsed time: 0.23206s