A Python project for enhancing images using various processing techniques.
Project description
Image Transformer
This Python application reads a .png image and generates a scalable .svg version. The .svg file can be used as a high-resolution wallpaper. The application samples the colors of each grid element (hexagon, square, etc) to reproduce the same picture.
Install
pip install image-transformer
How to use as a CLI tool ?
Example usage:
image-transformer [--help] [-g {hexagonal,square,triangle}] [-p {random,average,frequent}] [-s SIZE] image_path
Note: for more details about all the available params use the following command: image-transformer --help
.
How to use in a program ?
Example usage:
from PIL import Image
from image_transformer import ImageTransformer
from image_transformer.output_builders import CairoSvgOutputBuilder
from image_transformer.image_processors import HexagonalGridImageProcessor
from image_transformer.pixels_processors import MostFrequentPixelsProcessor
def main():
hexagon_size = 13
output_image_path = "result.svg"
# NOTE: assuming the image exists
my_image_path = "./testing-image.jpg"
image = Image.open(my_image_path)
transformer = ImageTransformer.from_pil_image(image)
output_builder = CairoSvgOutputBuilder(image.width, image.height, output_image_path)
image_processor = HexagonalGridImageProcessor(hexagon_size)
pixels_processor = MostFrequentPixelsProcessor()
transformer.transform_and_save(
image_processor=image_processor,
pixels_processor=pixels_processor,
output_builder=output_builder
)
if __name__ == "__main__":
main()
Examples
Original Image | Hexagonal SVG Version |
Development
Below are notes for development only. You don't need to give it a look unless you want to contribute or build your own library.
Materials & Notes:
This are for people who want to dig in hexagonal grids & know how to deal with it. Ignore if you only want to use the tool.
- https://www.redblobgames.com/
- https://www.geeksforgeeks.org/creating-svg-image-using-pycairo/
- https://gamedev.stackexchange.com/a/61101
Docs Building Notes
poetry add sphinx --dev
: to install sphinx.poetry run sphinx-apidoc -o docs/ src/
: to generate the .rst files for each module. This command should be run each time you have a new module or there is some changes in one of your modules.poetry run sphinx-build -b html docs docs/_build
: to build the documentation. Each time there is a change.
Upload to Pypi
poetry config http-basic.pypi __token__ <api-toke>
: to specify your pipy credentials.poetry build
: build the project.poetry publish
: to publish the builded project into pypi.
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
File details
Details for the file image_transformer-0.4.2.tar.gz
.
File metadata
- Download URL: image_transformer-0.4.2.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Windows/11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34624b5025ac02e954e0d5ff611e4357c7c3ff7624ab1f7445189abc99581233 |
|
MD5 | 35fa96cdaa79f28026061737139b4a1b |
|
BLAKE2b-256 | 81870eac08ffb40b2643b3fc5141a324f39174062704baee3c4e2ddfdb0f5209 |
File details
Details for the file image_transformer-0.4.2-py3-none-any.whl
.
File metadata
- Download URL: image_transformer-0.4.2-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Windows/11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4128766829319c8e30bdce2b95a7cbee53d8c2c343723b7d7b3901de531c8b50 |
|
MD5 | 9cdefcb04876be8b441714a32d80470f |
|
BLAKE2b-256 | 3719330628a50291f0cf6266a2e7198d362e57e7b89b48f2a70c6e0e81196843 |