How to generate a filmstrip image in python from a folder of images?
-
22-07-2019 - |
Question
I would like to do the equivalent off this (ruby code) in python for a Django project I am working on. I want to make a filmstrip image of X number of images in a folder.
Solution
Here is a function that wraps the contact sheet function S.Lott mentioned.
#!/usr/bin/env python
import os, os.path
from contactsheet import make_contact_sheet
def make_film_strip(fnames,
(photow,photoh),
(marl,mart,marr,marb),
padding):
return make_contact_sheet(fnames,
(1, len(fnames)),
(photow,photoh),
(marl,mart,marr,marb),
padding)
It is assuming the recipe is saved as contactsheet.py
. Usage is:
fstrip = filmstrip.make_film_strip(filmstrip.fnames, (120, 120), (0,0,0,0), 0)
fstrip.save('/path/to/file.format')
Tested.
OTHER TIPS
Do you mnean something like this? Use PIL to make a "contact sheet" of images?
Perhaps there are others here that are closer to what you want: http://code.activestate.com/recipes/tags/graphics/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow