\n")
count = count + 1
outfile.write("\n")
outfile.write(' '+fname+"\n")
PrintFooter(outfile)
print "\n"+outfilename+" written with "+str(count)+" images.\n"
def PrintHeader(fname,title):
header = """
""" + title + """
""" + title +"""
"""
fname.write(header)
def PrintFooter(fname):
fname.write (" \n\n\n")
def PrintHelp():
"""Help routine."""
print """
imgindex is a program to generate a web page with 'thumbnail' images
of all the image files located in the current directory.
Command-line options:
-f - output filename
-w - width of images in HTML file
-h - height of images in HTML file
-c - the number of columns in the resulting file
-a - index all formats (GIF, JPG and PNG) instead of just JPG
-t "title" - title for use in text and HTML
-? - print this help message
"""
def main():
"""Main routine"""
#
# Set defaults
#
width = 320
height = 240
fname = 'index.html'
numcolumns = 2
targets = ['jpg','JPG','jpeg','JPEG']
title = 'Index of Images'
try:
opts, args = getopt.getopt(argv[1:],"a?f:h:w:t:c:")
except getopt.error, msg:
stderr.write("\nimgindex: commandline error: "+ msg +"\n\n")
exit(1)
for i in opts:
if i[0] == '-h':
height = i[1]
elif i[0] == '-w':
width = i[1]
elif i[0] == '-f':
fname = i[1]
elif i[0] == '-?':
PrintHelp()
exit(0)
elif i[0] == '-a':
targets = ['jpg','JPG','jpeg','JPEG','gif','GIF','png','PNG']
elif i[0] == '-t':
title = i[1]
elif i[0] == '-c':
numcolumns = i[1]
try:
filecreate(fname,width,height,targets,title,numcolumns)
except:
stderr.write("\nError creating output file.\n\n")
if __name__ == '__main__' :
main()
|