Feb. 7th, 2011

foxfirefey: A guy looking ridiculous by doing a fashionable posing with a mouse, slinging the cord over his shoulders. (geek)
[personal profile] foxfirefey
Don't know if this could be useful to anyone else, but I just wrote a wee script that generates the HTML for images in a directory on my web server, to make it easier to post about them to my journal:

import Image, sys

if len(sys.argv) < 3:
    print "Usage: %s [baseurl] [filename] [filename] ..." % sys.argv[0]

# put this in front of each image file name
baseurl = sys.argv[1]

# cycle through all image names given on the command line
for imagefile in sys.argv[2:]:

    try:
        i = Image.open(imagefile)
        ( width, height ) = i.size
        print '<img src="%s/%s" width="%d" height="%d" alt="" />' \
          % ( baseurl, imagefile, width, height )
    except IOError:
        print "Could not process %s" % imagefile


Example of running it: )

February 2017

S M T W T F S
   1234
567891011
12131415161718
19202122232425
2627 28    

Style Credit

Expand Cut Tags

No cut tags