Skip to main content

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 objects
  • ratio=7/4 - required ratio of each image inside the collage. Default value is different for each function
  • bgcolor=(255, 255, 255, 255) - color of the background in RGBA format
  • spaceshare=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_3_1

collage_4_1

collage_4_1

collage_4_2

collage_4_2

collage_5_1

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)

Uploaded Source

File details

Details for the file social_collage-1.0.0.tar.gz.

File metadata

  • Download URL: social_collage-1.0.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for social_collage-1.0.0.tar.gz
Algorithm Hash digest
SHA256 da93bc9c04369678cfd724f0eb5b9c148f451cf9ff8eadbc5039157cf76bd8df
MD5 5581944769e3b05c1d38f1128d3d4e73
BLAKE2b-256 f44f85571f855f5f686029f135feb8e7704e5741f569b2637d36b62123134a97

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