3

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.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
espenhogbakk
  • 11,508
  • 9
  • 39
  • 38

2 Answers2

4

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
  • 384,516
  • 81
  • 508
  • 779
  • 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. – espenhogbakk Dec 02 '08 at 19:26
  • My thought is that the row number is always 0. Based on that, you can simplify this considerably. – S.Lott Dec 02 '08 at 19:39
1

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.

Community
  • 1
  • 1
muhuk
  • 15,777
  • 9
  • 59
  • 98
  • 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... – espenhogbakk Dec 02 '08 at 23:40