如何从图像文件夹中生成python中的幻灯片图像?

时间:2021-12-07 06:09:46

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.

我想在python中为我正在研究的Django项目做相同的(ruby代码)。我想在一个文件夹中制作X个图像的幻灯片图像。

2 个解决方案

#1


1  

Here is a function that wraps the contact sheet function S.Lott mentioned.

这是一个包含S.Lott提到的联系表函数的函数。

#!/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:

假设配方保存为contactsheet.py。用法是:

fstrip = filmstrip.make_film_strip(filmstrip.fnames, (120, 120), (0,0,0,0), 0)
fstrip.save('/path/to/file.format')

Tested.

#2


4  

Do you mnean something like this? Use PIL to make a "contact sheet" of images?

你有没有这样的事情?使用PIL制作图像的“联系表”?

Perhaps there are others here that are closer to what you want: http://code.activestate.com/recipes/tags/graphics/

也许这里有其他人更接近你想要的东西:http://code.activestate.com/recipes/tags/graphics/

#1


1  

Here is a function that wraps the contact sheet function S.Lott mentioned.

这是一个包含S.Lott提到的联系表函数的函数。

#!/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:

假设配方保存为contactsheet.py。用法是:

fstrip = filmstrip.make_film_strip(filmstrip.fnames, (120, 120), (0,0,0,0), 0)
fstrip.save('/path/to/file.format')

Tested.

#2


4  

Do you mnean something like this? Use PIL to make a "contact sheet" of images?

你有没有这样的事情?使用PIL制作图像的“联系表”?

Perhaps there are others here that are closer to what you want: http://code.activestate.com/recipes/tags/graphics/

也许这里有其他人更接近你想要的东西:http://code.activestate.com/recipes/tags/graphics/