Combine multiple images into one.
Project description
WallPaste
A tool that allows you to paste multiple images onto a background with respect of their aspect ratio.
This project is both a Python library/module and a CLI utility.
Requirements
Installation
- pip:
pip3 install wallpaste - cloning the repo and running
pip3 install -r requirements.txt
CLI
Example usage:
# If installed by PIP
python3 -m wp -i ~/Images -o ~/out.jpg -c 8
# or
python3 -m wp --input ~/Images --output ~/out.jpg --count 8
# If installed manually (git clone)
python3 /path/to/wp.py --input="~/Images" --output="~/out.jpg" --count=8
Flags
| Flag | Shorthand | Description | Required |
|---|---|---|---|
| --input | -i | Path to input directory | yes |
| --output | -o | Path to output file | no |
| --background | -b | Background color | yes* |
| --backgroundpath | -bp | Path to background image | yes* |
| --strictness | -s | Strictness number | no |
| --factor | -f | Starting scale factor | no |
| --width | -w | Target width (in px) | yes |
| --height | -he | Target height (in px) | yes |
| --count | -c | Number of images to merge | no |
| --margin | -m | Min distance between the edge and images | no |
| --padding | -p | Min distance between any side of a pic to another pic | no |
- backgroundpath only needs to be specified when background is not
Module usage
If you've installed this package using pip, you can import it like this:
import wallpaste
# or
from wallpaste import combine_images, generate_image
There are numerous function parameters to each function. No point in listing it all here, but their docs are located
next to their definition in thewallpaperproject.py.
def combine_images(input_path=None, images=None, output_path=None, target_size=None,
strictness=50, count=2, fact_main=2,
margin=0, padding=0, permutations=5,
bg_color="#eeeeee", background=None, background_path=None):
"""
This function will calculate the corresponding image sizes and their coordinates and paste them on
the background image without them intersecting.
:param input_path: input directory where source images are located
:param count: number of images to use (used with input_path)
:param images: list of full paths of images (does not have to be in the same directory)
:param output_path: output path where the generated image will be saved
:param target_size: tuple representing the target (width, height)
:param background: PIL Image object which will be used as the background
:param background_path: Path to the image that will be used as the background (use only if background is not specified)
:param bg_color: if background PIL image is not specified, use this to specify the background color
:param target_size: target image resolution
:param permutations: number of image order shuffles before changing the scaling factor by one
:param strictness: number of tries before making a permutation
:param fact_main: starting scaling factor
:param margin: minimal distance between the edges and placed images (in px)
:param padding: minimal distance between each image (in px)
:return:
"""
def generate_image(images, sizes, image_coords, output_path=None,
background=None, background_path=None,
bg_color="#eeeeee", target_size=(1920, 1080)):
"""
Paste images onto the background and output it to the output_path if defined,
if not, open the generated image in an image viewer.
:param images: list of full image paths
:param sizes: list of (width, height) tuples relating to every image
:param image_coords: list of (x,y) tuples representing the top left coordinates of every image
:param background: PIL Image which will be used as the background
:param background_path: Path to the image that will be used as the background (use only if background is not specified)
:param bg_color: if background PIL image is not specified, use this to specify the background color (used only with target_size)
:param target_size: target image resolution (used only with bg_color)
:param output_path: The generated image will be saved here
"""
Author
👤 Mišo Barišić
- Website: https://www.misobarisic.com
- GitHub: @misobarisic
- GitLab: @misobarisic
Show your support
Give a ⭐️ if this project helped you!
📝 License
This project is MIT licensed.
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 wallpaste-0.1.2.tar.gz.
File metadata
- Download URL: wallpaste-0.1.2.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce5b37f5ec6bca870d3a13c32591b1d706fb7383393dd90739d4598e33ce896e
|
|
| MD5 |
1edfb18a72a1509bb4563aae4e503218
|
|
| BLAKE2b-256 |
d170b2596f1903b216c970257d21ac7d721aa1b25414e0de53733dd3212675d8
|
File details
Details for the file wallpaste-0.1.2-py3-none-any.whl.
File metadata
- Download URL: wallpaste-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b180b8bcce67e25a0d4c471db89889570fbf8aa2f5a97e309fdf50e86fc231cc
|
|
| MD5 |
2028ebe21b6d57d1fa2c985ed436091f
|
|
| BLAKE2b-256 |
9f5110336a510439787b8eb82494809d7e61cd10fc8bddb71415c45d846b95d8
|