Python library to generate an image collage from other images. I mainly use it to generate horizontal wallpapers from multiple vertical images, but feel free to use it for any other purpuse.
Project description
Montafons
Python library to generate an image collage from other images. I mainly use it to generate horizontal wallpapers from multiple vertical images, but feel free to use it for any other purpuse. It is optimized for speed by using multiple threads to render images in paralel.
- Author: LluisE
- Source: https://github.com/lluises/montafons
- Licence: https://www.mozilla.org/en-US/MPL/2.0/
Usage
This python library can be used as a CLI tool or as a library for another project.
Use from the command line
Run montafons
usage: montafons [-h] -o OUTPUT [-H HEIGHT] [-W WIDTH] [-bc BGCOLOR] [-b BACKGROUND]
[-top BORDER_TOP] [-right BORDER_RIGHT] [-bottom BORDER_BOTTOM]
[-left BORDER_LEFT] [-smin SEPARATION_MIN] [-smax SEPARATION_MAX]
[-mw WIDTH_MIN] [-c CORRECTION_MAX] [-t] [-rn]
[images ...]
Make a montage with images
positional arguments:
images Images to process, or -
options:
-h, --help show this help message and exit
-o, --output OUTPUT Output file: "res.png"
-H, --height HEIGHT Output height in px, def:1080
-W, --width WIDTH Output width in px, def:total width of all images
-bc, --background-color BGCOLOR
Background color in hex. def:FFFFFF
-b, --background BACKGROUND
Background image (overwrites --background-color)
-top, --border-top BORDER_TOP
Top border in px
-right, --border-right BORDER_RIGHT
Right border in px
-bottom, --border-bottom BORDER_BOTTOM
Bottom border in px
-left, --border-left BORDER_LEFT
Left border in px
-smin, --separation-min SEPARATION_MIN
Minimum separation between images
-smax, --separation-max SEPARATION_MAX
Maximum separation between images
-mw, --min-width WIDTH_MIN
Minimum width (after resize) of an image to be added
-c, --correction CORRECTION_MAX
Maximum width correction when resizing images
-t, --transparentify Convert white pixels to transparent
-rn, --random Randomize image placement
Usage as a library
from montafons import Montafons
example_images = ['a.png', 'b.jpg', 'c.png']
params = {
"width": 1080,
"height": 1920,
# More parameters can be added, see the parametres section
}
mf = Montafons(**params)
for image in example_images:
mf.add(image)
mf.make("output.png")
Parameters
The Montafons class constructor accepts the following parameters:
*args ["/path/to/image.png", "img2.jpg"] (optional)
height int, in px (default 1080)
width int, in px (default -1, no width limit)
background "/path/to/image.png" or tuple(R, G, B)
bottom_top int, in px (default 0)
bottom_right int, in px (default 0)
bottom_bottom int, in px (default 0)
bottom_left int, in px (default 0)
separation_min int, in px (defalut 0)
separation_max int, in px (default 65536)
width_min int, in px (default 0)
correction_max int, in px (default 0)
transparentify bool (change white for transparent) (default false)
random bool (default false) Randomize image placement
LICENSE
This project is licenced under the Mozilla Public License version 2.0. You may obtain a copy of the licence at the LICENCE file in this repository, or online at https://www.mozilla.org/en-US/MPL/2.0/.
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 montafons-1.0.0.tar.gz.
File metadata
- Download URL: montafons-1.0.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97b96d75f67ec1cd5219821dd9a7827f87048a0a5159a1eb09b823f5125d9707
|
|
| MD5 |
32f2e414af15c571944e70e6b2e34976
|
|
| BLAKE2b-256 |
3715e7bcfab25fc2932cac0e75140e6695b484ee62330e6d4a3fc231c49b8347
|
File details
Details for the file montafons-1.0.0-py3-none-any.whl.
File metadata
- Download URL: montafons-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61e7ffaca8a00aadaba370f82a6b2d08e23288eee54cd47a9487d23b3bf3569b
|
|
| MD5 |
42cc5a5ed7c29c16b10e1f3998774e5f
|
|
| BLAKE2b-256 |
3ff9dcbe55a3dec976cee8388ced98cdf04c45e41098cddb5e00cb14a83ba78d
|