views:

281

answers:

2

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.

+3  A: 

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/

S.Lott
It's something like this, but this is over complicated, i want a singlecolumn "list" of images, and need the images to be loaded from a folder. I guess it is possible to modify that script to do that.
Espen Christensen
My thought is that the row number is always 0. Based on that, you can simplify this considerably.
S.Lott
+1  A: 

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.

muhuk
Thanks, the wrapping is good, thanks but i think i will try to make å decoupled solution, just modify the script and see if i can make it work...
Espen Christensen