Create image collages in social networks style
Project description
social_collage
Small and straightforward library based on PIL to create image collages similar to those in social networks.
Installation
pip install social_collage
Usage
import social_collage
images = [list of pil images]
collage = social_collage.collage_5_1(images)
collage.save(path to save)
Here social_collage.collage_5_1 is a function that makes the collage. It accepts collection of PIL images and returns a collage as another PIL image.
Currently available collage functions are: collage_3_1, collage_4_1, collage_4_2, collage_5_1.
Arguments, applicable to any collage function:
images- list of PIL image objectsratio=7/4- required ratio of each image inside the collage. Default value is different for each functionbgcolor=(255, 255, 255, 255)- color of the background in RGBA formatspaceshare=150- share of the first image width to use as a space size. 0 or None means no space between images
Full example
replace path with your own, or use files from "package/example_images"
import glob
from pathlib import Path
from PIL import Image
import social_collage
# Read image files into a list of PIL objects
imgs = []
for imgpath in sorted(glob.glob('your_image_folder/*.jpg')):
imgs.append(Image.open(imgpath))
# Send list of PIL images to a collage function
collage = social_collage.collage_5_1(imgs)
# Show the returned PIL image containing the resulting collage
collage.show()
This example can also be launched with
import social_collage
social_collage.example()
Results
collage_3_1
collage_4_1
collage_4_2
collage_5_1
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
social_collage-1.0.0.tar.gz
(2.0 MB
view details)
File details
Details for the file
social_collage-1.0.0.tar.gz.File metadata
File hashes
da93bc9c04369678cfd724f0eb5b9c148f451cf9ff8eadbc5039157cf76bd8df5581944769e3b05c1d38f1128d3d4e73f44f85571f855f5f686029f135feb8e7704e5741f569b2637d36b62123134a97See more details on using hashes here.