#!/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 = """
Моя галерея
Photo Album
"""
return input
# Подвал html-страницы
def add_html_bottom():
input = """
"""
return input
# Одна строка таблицы
def add_html_line(ls):
input = """
"""
for i in ls:
one = " | \n"
input = input+one
input = input + """
"""
for i in ls:
one = "\n"
one = one+"Full \n"
one = one+"Small \n"
one = one+"EXIF \n"
one = one+" | \n"
input = input+one
input = input + """
|
"""
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()