[Comm] web album generator
Kolotov Alexandr
akmypost ÎÁ mail.ru
þÔ íÁÒ 17 16:13:30 MSK 2005
> Может ктото из community уже сталкивался с подобной проблемой и может
> чтото посоветовать?
mum поищите на CITKIT.ru или sourceforge...
если есть навыки программирования на Shell/perl/python можете свое
сваять за короткое время - я для этих целей пользовался инструментарием
из ImageMagick, можно еще пользоваться отдельной тулзой exif...
См. вложение - формирует на стандартный вывод содержимое html-страницы
--
С уважением, Kolotov Alexandr aka mr. Эбола
отвечать: akmypost ÎÁ mail.ru
ICQ: 100349254
---------------------------------------
| Registered Linux user # 236664 |
---------------------------------------
----------- ÓÌÅÄÕÝÁÑ ÞÁÓÔØ -----------
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
# Где лежат исходные кратинки
path_to_images = "images/"
# Здесь будут лежать уменьшенные копии размером 800x600
path_to_small = "small/"
# Здесь будут лежать превьюшки 120x90
path_to_thumb = "thumb/"
# Здесь будет лежать мета-информация
path_to_exif = "exif/"
# Кол-во фоток в строке
images_in_line = 4
# Шапка html-страницы
def add_html_top():
input = """<html>
<head>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=utf8'>
<title>Моя галерея</title>
</head>
<body>
<center>
<h3>Photo Album</h3>
<table border="1" cellspacing="1">
"""
return input
# Подвал html-страницы
def add_html_bottom():
input = """ </table>
</center>
</body>
</html>"""
return input
# Одна строка таблицы
def add_html_line(ls):
input = """ <tr align="center"><td>
<table border="0" cellpadding="10" cellspacing="0">
<tr align="center" valign="center">
"""
for i in ls:
one = "<td><a href=\""+i['image']+"\"><img src=\""+i['thumb']+"\" border='0' alt='' /></a></td>\n"
input = input+one
input = input + """ </tr>
<tr align="center" valign="center">
"""
for i in ls:
one = "<td>\n"
one = one+"<a href=\""+i['image']+"\"><font size='-2'>Full</font></a> \n"
one = one+"<a href=\""+i['small']+"\"><font size='-2'>Small</font></a> \n"
one = one+"<a href=\""+i['exif']+"\"><font size='-2'>EXIF</font></a> \n"
one = one+"</td>\n"
input = input+one
input = input + """ </tr>
</table>
</td></tr>
"""
return input
def main():
files = os.listdir(path_to_images)
print add_html_top()
for i in xrange(0, len(files), images_in_line):
l = []
end_iter = i+images_in_line
if end_iter > len(files):
end_iter = len(files)
for j in xrange(i, end_iter):
d = {}
d['image'] = path_to_images+files[j]
d['small'] = path_to_small+files[j]
d['thumb'] = path_to_thumb+files[j]
d['exif'] = path_to_exif+files[j].split('.')[0]+".txt"
l.append(d)
cmd = "exif "+d['image']+" > "+d['exif']
os.system(cmd)
cmd = "convert -size 800x800 "+d['image']+" -resize 800x800 +profile \"*\" "+d['small']
os.system(cmd)
cmd = "convert -size 120x120 "+d['image']+" -resize 120x120 +profile \"*\" "+d['thumb']
os.system(cmd)
print add_html_line(l)
print add_html_bottom()
if __name__ == '__main__':
main()
ðÏÄÒÏÂÎÁÑ ÉÎÆÏÒÍÁÃÉÑ Ï ÓÐÉÓËÅ ÒÁÓÓÙÌËÉ Community