Skip to main content

An Open Source Python library for creating photomosaics

Project description

PytoMosaic

PytoMosaic is a Python library for creating photomosaics from images using a set of source images. It supports common image formats and provides a simple API with optional verbose progress output. It also allows reusing preloaded tiles for faster mosaic generation across multiple images.


Features

  • Create photomosaics from images
  • Supports .jpg, .jpeg, .png, .gif, .bmp, .tiff, .tif formats
  • Optional verbose mode with progress bars using tqdm
  • Reuse preloaded tiles with TileManager for multiple mosaics
  • Easy-to-use Python API
  • Compatible with Python 3.10+
  • Ability to save files
  • Image downloader for fast downloads

Installation

Install PytoMosaic from PyPI:

pip install pytomosaic

Dependencies:

  • numpy
  • Pillow
  • tqdm

These will be installed automatically.


Usage

Basic usage

from pytomosaic import createMosaic

imgPath = "target.jpg"
sourceImages = "source_folder"
cropSize = 50  # Size of mosaic parts in px

# Generate mosaic with verbose progress
mosaic = createMosaic(imgPath, sourceImages, cropSize, verbose=True, savePath="example.jpg")
mosaic.show()

Reusing preloaded tiles for multiple images

from pytomosaic import createMosaic
from pytomosaic.tileManager import TileManager

# Preload tiles once
tiles = TileManager(cropSize=50, sourceImagesDir="source_folder", verbose=True)

# Generate multiple mosaics using the same tiles
mosaic1 = createMosaic("photo1.jpg", tiles)
mosaic2 = createMosaic("photo2.jpg", tiles)

Set verbose=False or leave empty to disable prints and progress bars.

Downloading images from pixabay

from pytomosaic import downloadImages

key = "YOUR_API_KEY" # Get from Pixabay
amount = 200 # 200 Maximum due to pixabay restriction
query = "Your Query" # What you want the pictures to be of
pathToDownloadTo = "path/to/download/to"

downloadImages(key, amount, query, pathToDownloadTo, verbose=True)

Supported Image Extensions

VALID_EXTENSIONS = {
    ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif"
}

Files with unsupported extensions are skipped and optionally warned about in verbose mode.


License

PytoMosaic is licensed under the GNU GPL v3. See the LICENSE file for details.

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

pytomosaic-0.1.12.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytomosaic-0.1.12-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file pytomosaic-0.1.12.tar.gz.

File metadata

  • Download URL: pytomosaic-0.1.12.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pytomosaic-0.1.12.tar.gz
Algorithm Hash digest
SHA256 b3ca46ad06d367e195d66ec6bf036557266443396b23a1edd22f0fc4e6c77a9e
MD5 a265eb820ddb7187d6be9ec559e87959
BLAKE2b-256 9328c51ea778498f765abc4c35a9dcb52319e344147c1f2fa66e45e89222be06

See more details on using hashes here.

File details

Details for the file pytomosaic-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: pytomosaic-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pytomosaic-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 9a894a5d14b7d51c39bdab950cc665895a9c071ca1fde6e2cf7623503d501a23
MD5 a7c33d77759b96d0a8de8ad37ad444d4
BLAKE2b-256 3ebf8ad59bec13de482c7a0608ccde147fd157d4266a369ac102615364048c73

See more details on using hashes here.

Supported by

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