#! /usr/bin/env python """ Coverts images in a directory into smaller reslution copies and creates overview in html format. ver.: 20030807 Copyright (c) 2003 Jiri Baum This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ # vyrobi male a stredni nahledy k obrazkum (system tso) a prislusny soubor html import os, re, string prefix = os.path.basename(os.path.abspath('.')) orig = prefix for d in (orig, 's'): try: os.mkdir(d) except OSError: pass for a in os.listdir('.'): if not os.path.isfile(a) or re.search('-t\.',a,re.I): continue m = re.match('(.*?)(-o)?\.(jpe?g)', a, re.I) if not m: continue (base,None,ext) = m.groups() base = prefix + "-" + base print a res=os.system("djpeg "+a+" | pnmscale -pixels 500000 | "+ "cjpeg -quality 50 > s/"+base+"-s.jpg") if res: raise "making small version returned "+str(res) res=os.system("djpeg s/"+base+"-s.jpg | pnmscale -xysize 240 240 | cjpeg -quality 50 "+ "> "+base+"-t.jpg") if res: raise "making thumbnail returned "+str(res) res=os.system("mv -i "+a+" "+os.path.join(orig,base+"-o.jpg")) if res: raise "moving original returned "+str(res) f = open(os.path.join("..",prefix+".html"),"w") seznam = os.listdir('.') seznam.sort() f.write(""" """+prefix+""" - fotky

"""+prefix+""" - fotky

""") for a in seznam: if not os.path.isfile(a) or not re.search('\.jpe?g',a,re.I): continue try: base = re.match('(.*)-t.jpg', a).group(1) except: base = "unknown" f.write("" "\n") f.write("""
""") f.close()