Skip to main content

A Python project for enhancing images using various processing techniques.

Project description

Coverage Python Poetry


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}] [-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.cairo_svg_output_builder import CairoSvgOutputBuilder
from image_transformer.image_processors.hexagonal_grid_image_processor import HexagonalGridImageProcessor
from image_transformer.pixels_processors.most_frequent_pixels_processor 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()

    # NOTE: ignore
    callback = lambda step, value: ""

    transformer.transform_and_save(
        image_processor=image_processor,
        pixels_processor=pixels_processor,
        output_builder=output_builder,
        callback=callback
    )

if __name__ == "__main__":
    main()

Examples

Original Image Generated SVG
Original Image Generated SVG
Original Image Generated SVG

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.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

image_transformer-0.4.0.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

image_transformer-0.4.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file image_transformer-0.4.0.tar.gz.

File metadata

  • Download URL: image_transformer-0.4.0.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Windows/11

File hashes

Hashes for image_transformer-0.4.0.tar.gz
Algorithm Hash digest
SHA256 8df04bdc9c1d195b1cea768e0794a9c270191242d414353c8a40a3545fb74a94
MD5 2ff5c64613d9c5cc865f96ca629e83c8
BLAKE2b-256 69b656512755b78c46559eb8715ca73febd7293bb29d8e13c4be0e3af9d4e074

See more details on using hashes here.

File details

Details for the file image_transformer-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for image_transformer-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31cbb5b78c854139cf3844f10b47ab40683f333fee5fbd27c2788f655bdbc373
MD5 eea78b44c842348fc82f32696f9619b4
BLAKE2b-256 32ca06b0a22f1ff7082bbdcde4a1b85bce24a9d92a365ab736029772e1984a5e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page