Skip to content

Create a mosaic of an input image using smaller images of similar color to each pixel.

License

Notifications You must be signed in to change notification settings

VictorWesterlund/collage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Collage

Create a collage of an image using smaller images

demo

Full resolution output (4000x4000px)

Create your own

Prerequisites

  1. Install the pip package manager for Python 3.
sudo apt-get install python3-pip
  1. Install dependencies from requirements.txt.
python3 -m pip install -r requirements.txt

Create a collage

  1. Add JPG images to use as samples to the samples/ folder. 9999 free sample images.

Sample sets containing images with a mix of different colors and light intensity will in general produce better results.

  1. Run create.py from ~/collage with Python 3.
python3 create.py
  1. Provide an input and output file path when prompted.

You can also pass the input and output file paths as arguments when running create.py.

python3 create.py [path_to_input] [path_to_output]

Download sample images

9999 free 612x612px sample images (~1GB when inflated).

Note that 9999 images are probably overkill if the samples are random enough (which these are). 2000-4000 samples should be enough for most use cases.

Set Size Download
1-2000 193.5 MB Download
2001-4000 192.2 MB Download
4001-6000 191.2 MB Download
6001-8000 380.5 MB Download
8001-10000 191.4 MB Download

Increase / Decrease the output resolution

Resizing the output doesn't require any modification to the underlying code. It does however require that you instance each class manually.

  1. Import the required modules.
from classes.Samples import Samples
from classes.Collage import Collage
  1. Loading the samples with Sample. Nothing exciting here.
samples = Samples("samples",False)
  1. Initialize Collage and define your own self.size tuple.
collage = Collage("path/to/input.jpg",samples)
collage.size = (100,50) # (width,height) of each sample in the collage.

collage.put("path/to/write/output.jpg")

License

This repo is licensed under the MIT License

Issues & Contribute

Report bugs and suggest features by creating an Issue.

Pull Requests to this repo are very appreciated.

About

Create a mosaic of an input image using smaller images of similar color to each pixel.

Topics

Resources

License

Stars

Watchers

Forks

Languages