ImageConverter is a Python Package that provides methods to convert images between different formats, such as bytes and base64 encoding. It uses the OpenCV library for image processing.
Project description
ImageConverter
ImageConverter is a Python Packages that provides methods to convert images between different formats, such as bytes and base64 encoding. It uses the OpenCV library for image processing.
Installation
To use the ImageConverter class, you need to have OpenCV installed. You can install it using pip:
pip install opencv-python
Usage
First, import the necessary modules:
Then, import and create an instance of the ImageConverter class:
converter = ImageConverter()
Loading an Image
To load an image from a file, use the load_image method:
converter.load_image('path/to/image.jpg')
Converting Image to Bytes
To convert the loaded image to bytes, use the image_to_bytes method:
image_bytes = converter.image_to_bytes()
Converting Bytes to Image
To convert bytes back to an image, use the bytes_to_image method:
image = converter.bytes_to_image(image_bytes)
Encoding Image to Base64
To encode the image as a base64 string, use the encode_image_to_base64 method:
encoded_image = converter.encode_image_to_base64()
Decoding Base64 to Image
To decode a base64-encoded image back to an image, use the decode_base64_to_image method:
decoded_image = converter.decode_base64_to_image(encoded_image)
Saving Decoded Image
To save the decoded image to a file, use the save_decoded_image method:
converter.save_decoded_image('path/to/output.jpg')
Examples
Here's an example that demonstrates how to use the ImageConverter class:
from image_converter import ImageConverter
# Create an instance of the ImageConverter class
converter = ImageConverter()
# Load an image
converter.load_image('path/to/image.jpg')
# Convert the image to bytes
image_bytes = converter.image_to_bytes()
# Convert bytes back to an image
image = converter.bytes_to_image(image_bytes)
# Encode the image as a base64 string
encoded_image = converter.encode_image_to_base64()
# Decode the base64 image back to an image
decoded_image = converter.decode_base64_to_image(encoded_image)
# Save the decoded image
converter.save_decoded_image('path/to/output.jpg')
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please create an issue or submit a pull request.
License
This project is open source and licensed under the MIT License.
Contact
For any questions or inquiries, please contact:
- Muhammad Tanveer Sultan
- Email: engr.tanveersultan53@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file image_converters-0.1.1.tar.gz.
File metadata
- Download URL: image_converters-0.1.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e5134ef58fbdd6a6487ea34bc966feb845ba414b035a5b2b33e7bcaaeac3fe4
|
|
| MD5 |
f326a6eaedd993c4f6950260aa1765a0
|
|
| BLAKE2b-256 |
e313d64efaee2072094b7fce5b990afa7e48bf48f202b2a014d786a2cc1cf57f
|
File details
Details for the file image_converters-0.1.1-py3-none-any.whl.
File metadata
- Download URL: image_converters-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f654e3f7f108c585ce4c0a65553caf3c5028e8a4531753d069649298886b0782
|
|
| MD5 |
7c45fe5495cc9bad311a843e8a85f7b6
|
|
| BLAKE2b-256 |
722dca6e23ac86122a2d7c31e01f57af3494985901fb4dd39e674a4e3d6270eb
|