Emin now makes passable galleries and supports PDF, EPS and TIFF conversion

Tue, 10 Feb 2009 13:41:49 +0000

author
andy
date
Tue, 10 Feb 2009 13:41:49 +0000
changeset 9
38012d2998c1
parent 8
209609a6c525
child 10
e0d5bcbe6c62

Emin now makes passable galleries and supports PDF, EPS and TIFF conversion

emin file | annotate | diff | comparison | revisions
lightbox.zip file | annotate | diff | comparison | revisions
     1.1 --- a/emin	Sun Nov 23 20:25:31 2008 +0000
     1.2 +++ b/emin	Tue Feb 10 13:41:49 2009 +0000
     1.3 @@ -3,7 +3,8 @@
     1.4  
     1.5  version = "%prog 0.2"
     1.6  
     1.7 -usage="""
     1.8 +usage="""%prog [opts] dir [outdir]
     1.9 +
    1.10  %prog - a static web gallery builder
    1.11  
    1.12  by Andy Buckley
    1.13 @@ -16,14 +17,10 @@
    1.14  As for the name, this is a program to make pretty 
    1.15  crappy galleries, so it's named after a pretty crappy 
    1.16  artist. And, thankfully, e-m-i-n is not many characters
    1.17 -to type (and they're all close together on my Colemak
    1.18 +to type (and they're all close together on the Colemak
    1.19  keyboard layout) --- trebles all round!
    1.20  
    1.21 -Usage: 
    1.22 -%prog [opts] dir [outdir]
    1.23 -
    1.24  TODO:
    1.25 - * Use Cheetah templates (from file or built-in string)
    1.26   * Try to import BeautifulSoup for validating/pretty-printing the output
    1.27   * Use thickbox, jQuery, Lightbox2 etc.
    1.28   * Rename images before starting
    1.29 @@ -58,8 +55,6 @@
    1.30  parser.add_option("--no-table", dest="USE_TABLE", action="store_false", default=True, 
    1.31                    help="don't use an HTML table for thumbnail presentation: just let the thumbs flow into the browser window")
    1.32  verbgroup = OptionGroup(parser, "Verbosity control")
    1.33 -parser.add_option("-l", dest="NATIVE_LOG_STRS", action="append",
    1.34 -                  default=[], help="set a log level in the Rivet library")
    1.35  verbgroup.add_option("-V", "--verbose", action="store_const", const=logging.DEBUG, dest="LOGLEVEL",
    1.36                       default=logging.INFO, help="print debug (very verbose) messages")
    1.37  verbgroup.add_option("-Q", "--quiet", action="store_const", const=logging.WARNING, dest="LOGLEVEL",
    1.38 @@ -75,34 +70,34 @@
    1.39  
    1.40  
    1.41  ## TODO: These should be options...
    1.42 -opts.OUTDIR = None
    1.43  opts.RENAME = False
    1.44  opts.CONVERT = False
    1.45  
    1.46  
    1.47  ## Set processing/output dir
    1.48 -if len(args) != 1:
    1.49 -    #print parser.show_usage()
    1.50 -    sys.exit(1)
    1.51 -opts.SRCDIR = args[0]
    1.52 -if opts.OUTDIR == None:
    1.53 -    opts.OUTDIR = args[0]
    1.54 +if len(args) < 1 or len(args) > 2:
    1.55 +    print parser.show_usage()
    1.56 +    exit(1)
    1.57 +if len(args) >= 1:
    1.58 +    opts.SRCDIR = os.path.normpath(args[0])
    1.59 +    opts.OUTDIR = os.path.normpath(args[0])
    1.60 +if len(args) == 2:
    1.61 +    opts.OUTDIR = os.path.normpath(args[1])
    1.62  
    1.63  
    1.64  ## Try to import Cheetah templating
    1.65 -## TODO Should be closer to where it's used? Does default need Cheetah?
    1.66  try:
    1.67      from Cheetah.Template import Template
    1.68  except Exception, e:
    1.69 -    logging.error("Couldn't import required Python Cheetah package")
    1.70 -    sys.exit(1)
    1.71 +    logging.error("Couldn't import required Cheetah package")
    1.72 +    exit(1)
    1.73  
    1.74  ## Try to import Python Imaging Library
    1.75  try:
    1.76      import PIL.Image as PILI
    1.77  except Exception, e:
    1.78      logging.error("Couldn't import required Python Imaging Library package")
    1.79 -    sys.exit(1)
    1.80 +    exit(1)
    1.81  
    1.82  
    1.83  def safeencode(s):
    1.84 @@ -114,103 +109,167 @@
    1.85  logging.debug("Thumb height: %d" % opts.THUMB_HEIGHT)
    1.86  
    1.87  
    1.88 -class ImageInfo:
    1.89 +class ImageInfo(object):
    1.90      def __init__(self):
    1.91 +        self.name = None
    1.92          self.path = None
    1.93 -        self.x = None
    1.94 -        self.y = None
    1.95 -    def _setsize(self, sizetuple):
    1.96 -        self.x = sizetuple[0]
    1.97 -        self.y = sizetuple[1]
    1.98 +        self.thumbname = None
    1.99 +        self.thumbpath = None
   1.100 +        self.thumbx = None
   1.101 +        self.thumby = None
   1.102 +
   1.103 +    def setsize(self, sizetuple):
   1.104 +        self.thumbx = sizetuple[0]
   1.105 +        self.thumby = sizetuple[1]
   1.106 +
   1.107      def _getsize(self):
   1.108 -        return self.x, self.y
   1.109 -    size = property(_getsize, _setsize)
   1.110 +        return self.thumbx, self.thumby
   1.111 +
   1.112 +    thumbsize = property(_getsize, setsize)
   1.113  
   1.114  
   1.115  ## Go to the gallery directory and test if it's writeable
   1.116  if not os.access(opts.OUTDIR, os.W_OK):
   1.117 -    logging.error("Directory %s is not writeable" % opts.OUTDIR)
   1.118 -    sys.exit(1)
   1.119 +    try:
   1.120 +        logging.info("Making output dir in %s" % opts.OUTDIR)
   1.121 +        os.makedirs(opts.OUTDIR)
   1.122 +    except Exception, e:
   1.123 +        logging.error("Problem when making output dir %s... exiting" % opts.OUTDIR)
   1.124 +        #traceback.print_exc()
   1.125 +        exit(1)
   1.126  
   1.127 -
   1.128 -## Rename images
   1.129 -if opts.RENAME:
   1.130 -    ## TODO: types: PNG/GIF, JPEG, PDF
   1.131 -    ## TODO: match formats & store thumb filenames
   1.132 -    for n, img in enumerate(glob.glob(["*.jpg", "*.jpeg", "*.JPG"])):
   1.133 -        newname = "%s-%03d.jpg" % (safename(opts.OUTDIR), n)
   1.134 -        if img != newname:
   1.135 -            logging.debug("Renaming %s -> %s" % (img, newname))
   1.136 -            shutils.mv(img, newname)
   1.137 -
   1.138 -
   1.139 -## TODO: Convert unviewables (TIF(F), PDF, EPS, ...) to JPG/PNG (keep link to originals)
   1.140 -if opts.CONVERT:
   1.141 -    pass
   1.142 -
   1.143 -
   1.144 -## Build the list of pictures to display
   1.145 -EXTENSIONS = ["*.jpg", "*.jpeg", "*.tif", "*.tiff", 
   1.146 -              "*.png", "*.gif", "*.gif",
   1.147 -              "*.eps", "*.pdf"]
   1.148 -pics = []
   1.149 -ROOTDIR = os.getcwd()
   1.150 -os.chdir(opts.SRCDIR)
   1.151 -for e in EXTENSIONS:
   1.152 -    pics += glob.glob(e)
   1.153 -    pics += glob.glob(e.upper())
   1.154 -os.chdir(ROOTDIR)
   1.155 -print sorted(pics)
   1.156 -
   1.157 -
   1.158 -## Make thumbnails if needed
   1.159 -THUMBDIR = "thumbs"
   1.160 -thumbdir = opts.OUTDIR
   1.161 -thumbsinfo = {}
   1.162 +## Make thumbnail directory if needed
   1.163 +opts.THUMBDIR = "thumbs"
   1.164 +THUMBDIR = os.path.join(opts.OUTDIR, opts.THUMBDIR)
   1.165  try:
   1.166 -    thumbdir = os.path.join(opts.OUTDIR, THUMBDIR)
   1.167 -    if not os.path.isdir(thumbdir):
   1.168 -        logging.info("Making thumbs dir in %s" % thumbdir)
   1.169 -        os.makedirs(thumbdir)
   1.170 +    if not os.path.isdir(THUMBDIR):
   1.171 +        logging.info("Making thumbs dir in %s" % THUMBDIR)
   1.172 +        os.makedirs(THUMBDIR)
   1.173  except Exception, e:
   1.174      logging.error("Problem when making thumbnails dir... exiting")
   1.175      #traceback.print_exc()
   1.176 -    sys.exit(1)
   1.177 -try:
   1.178 -    for pic in pics:
   1.179 -        ## TODO: Un-hard-code PNG thumb format
   1.180 -        thumbpic = pic + ".png"
   1.181 -        thumbpath = os.path.join(thumbdir, thumbpic)
   1.182 -        if opts.FORCE or not os.access(thumbpath, os.R_OK) \
   1.183 -                or os.stat(thumbpath).st_mtime > os.stat(pic).st_mtime:
   1.184 -            logging.debug("Making new thumbnail %s for %s (max height %d)" % \
   1.185 -                          (thumbpath, pic, opts.THUMB_HEIGHT))
   1.186 -            thumbimg = PILI.open(os.path.join(opts.SRCDIR, pic), "r")
   1.187 -            thumbimg.thumbnail((100000000, opts.THUMB_HEIGHT), resample=PILI.ANTIALIAS)
   1.188 -            info = ImageInfo()
   1.189 -            info.path = thumbpic
   1.190 -            info.size = thumbimg.size
   1.191 -            thumbsinfo[thumbpic] = info
   1.192 -            #thumbimg.show()
   1.193 -            thumbimg.save(thumbpath)
   1.194 -except Exception, e:
   1.195 -    logging.warning("Problem when making thumbnail... exiting")
   1.196 -    #traceback.print_exc()
   1.197 -    #sys.exit(1)
   1.198 +    exit(1)
   1.199  
   1.200  
   1.201 +## Build the list of pictures to display
   1.202 +## TODO: types: PNG/GIF, JPEG, PDF
   1.203 +## TODO: match formats & store thumb filenames
   1.204 +EXTENSIONS = \
   1.205 +    ["*.jpg", "*.jpeg"] + \
   1.206 +    ["*.png", "*.gif"]  + \
   1.207 +    ["*.tif", "*.tiff"] + \
   1.208 +    ["*.eps", "*.pdf"]
   1.209 +imgs = []
   1.210 +import fnmatch
   1.211 +for img in os.listdir(opts.SRCDIR):
   1.212 +    for e in EXTENSIONS:
   1.213 +        if fnmatch.fnmatch(img, e):
   1.214 +            imgpath = os.path.join(opts.SRCDIR, img)
   1.215 +            imgs.append(imgpath)
   1.216 +            break
   1.217 +
   1.218  ## Count the pictures
   1.219 -logging.debug("Number of pictures = %d" % len(pics))
   1.220 -if len(pics) == 0:
   1.221 +logging.debug("Number of pictures = %d" % len(imgs))
   1.222 +if len(imgs) == 0:
   1.223      logging.debug("No pictures from which to build a gallery...")
   1.224 -    sys.exit(2)
   1.225 +    exit(2)
   1.226 +logging.debug("Images: " + str(sorted(imgs)))
   1.227  
   1.228  
   1.229 +## Rename/move if needed
   1.230 +outimgs = []
   1.231 +for n, imgpath in enumerate(imgs):
   1.232 +    imgname = os.path.basename(imgpath)
   1.233 +    imgnameparts = os.path.splitext(imgname)
   1.234 +    targetname = imgname
   1.235 +    if opts.RENAME:
   1.236 +        targetname = "%s-%03d%s" % (safename(opts.OUTDIR), n, imgnameparts[1])
   1.237 +    targetpath = os.path.join(opts.OUTDIR, targetname)
   1.238 +    outimgs.append(targetpath)
   1.239 +    if imgpath != targetpath:
   1.240 +        logging.debug("Copying %s -> %s" % (imgpath, targetpath))
   1.241 +        import shutil
   1.242 +        shutil.copy(imgpath, targetpath)
   1.243 +
   1.244 +
   1.245 +## Store some image info
   1.246 +imgsinfo = {}
   1.247 +for picpath in outimgs:
   1.248 +    picname = os.path.basename(picpath)
   1.249 +    picbase = os.path.splitext(picname)[0]
   1.250 +
   1.251 +    ## Convert EPS, PDF, TIFF to Web-viewable formats
   1.252 +    picversions = {}
   1.253 +    picpathparts = os.path.splitext(picpath)
   1.254 +    picnameparts = os.path.splitext(picname)
   1.255 +    extn = picnameparts[1].lower()
   1.256 +    convcmd = None
   1.257 +    if extn in [".tif", ".tiff"]:
   1.258 +        picversions["TIFF"] = picname
   1.259 +        newpicname = picname + ".jpg"
   1.260 +        newpicpath = picpath + ".jpg"
   1.261 +        picversions["JPG"] = newpicname
   1.262 +        convcmd = ["convert", picpath, newpicpath]
   1.263 +        picname = newpicname
   1.264 +        picpath = newpicpath
   1.265 +    elif extn in [".eps", ".pdf"]:
   1.266 +        picversions[extn[1:].upper()] = picname
   1.267 +        newpicname = picname + ".png"
   1.268 +        newpicpath = picpath + ".png"
   1.269 +        picversions["PNG"] = newpicname
   1.270 +        convcmd = ["convert", "-density", "200", picpath, newpicpath]
   1.271 +        picname = newpicname
   1.272 +        picpath = newpicpath
   1.273 +    else:
   1.274 +        picversions[extn[1:].upper()] = picname
   1.275 +
   1.276 +    ## Do the conversion
   1.277 +    if convcmd:
   1.278 +        try:
   1.279 +            import subprocess
   1.280 +            subprocess.check_call(convcmd)
   1.281 +        except:
   1.282 +            raise
   1.283 +
   1.284 +    ## Main pic info
   1.285 +    info = ImageInfo()
   1.286 +    info.name = picname
   1.287 +    info.path = picpath
   1.288 +    info.versions = picversions
   1.289 +
   1.290 +    ## Thumb info
   1.291 +    ## TODO: Un-hard-code PNG thumb format
   1.292 +    thumbname = picname + ".png"
   1.293 +    thumbpath = os.path.join(THUMBDIR, thumbname)
   1.294 +    info.thumbname = thumbname
   1.295 +    info.thumbpath = thumbpath
   1.296 +
   1.297 +    ## Make thumbnail
   1.298 +    ## TODO: Be lazy!
   1.299 +    #if opts.FORCE or not os.access(thumbpath, os.R_OK) or os.stat(thumbpath).st_mtime > os.stat(pic).st_mtime:
   1.300 +    try:
   1.301 +        logging.debug("Making new thumbnail %s for %s (max height %d)" % \
   1.302 +                          (thumbpath, picname, opts.THUMB_HEIGHT))
   1.303 +        thumbimg = PILI.open(picpath, "r")
   1.304 +        thumbimg.thumbnail((100000000, opts.THUMB_HEIGHT), resample=PILI.ANTIALIAS)
   1.305 +        thumbimg.save(thumbpath)
   1.306 +        info.thumbsize = thumbimg.size
   1.307 +    except Exception, e:
   1.308 +        logging.warning("Problem when making thumbnail from %s... exiting" % picpath)
   1.309 +        #traceback.print_exc()
   1.310 +        exit(1)
   1.311 +
   1.312 +    ## Store info
   1.313 +    imgsinfo[picname] = info
   1.314 +
   1.315 +
   1.316 +#####################
   1.317 +
   1.318  
   1.319  ## Calculate how many pages will be needed
   1.320  ## TODO: allow all on one page
   1.321  NUM_PER_PAGE = opts.NUM_ROWS * opts.NUM_COLS
   1.322 -NUM_PAGES = int(math.ceil( len(pics)/float(NUM_PER_PAGE) ))
   1.323 +NUM_PAGES = int(math.ceil( len(imgs)/float(NUM_PER_PAGE) ))
   1.324  
   1.325  
   1.326  ## TODO: Move HTML extension-setting to option parser 
   1.327 @@ -219,7 +278,7 @@
   1.328  
   1.329  
   1.330  def getPageFilename(pagenum):
   1.331 -    if pagenum == 0:
   1.332 +    if pagenum == 1:
   1.333          pagefile = "index.%s" % opts.EXTN
   1.334      else:
   1.335          pagefile = "index%02d.%s" % (pagenum, opts.EXTN)
   1.336 @@ -253,29 +312,101 @@
   1.337      return out
   1.338  
   1.339  
   1.340 -# Make a zip archive
   1.341 -if opts.WRITE_ZIPFILE:
   1.342 +## Make a zip archive
   1.343 +ZIPFILE = "photo-album.zip"
   1.344 +if True: #opts.WRITE_ZIPFILE:
   1.345      logging.debug("Making zipped picture archive")
   1.346 -    ZIPFILE = "photo-album.zip"
   1.347      if opts.ZIPFILE is not None:
   1.348          ZIPFILE = opts.ZIPFILE
   1.349      elif opts.TITLE is not None or len(opts.TITLE) > 0:
   1.350          ZIPFILE = safeencode(opts.TITLE)
   1.351          #ZIPFILE = safename(opts.OUTDIR)
   1.352 -    if ZIPFILE.split(".")[-1] != "zip":
   1.353 +    if not "." in ZIPFILE or os.path.splitextn(ZIPFILE)[1] != ".zip":
   1.354          ZIPFILE += ".zip"
   1.355 -    ## TODO: Do the zipping
   1.356 -    #import zipfiles
   1.357 -    #rm -f *.zip
   1.358 -    ##zip $ZIPFILE $pics &> /dev/null
   1.359 +    ## Do the zipping
   1.360 +    from zipfile import ZipFile
   1.361 +    zf = ZipFile(os.path.join(opts.OUTDIR, ZIPFILE), "w")
   1.362 +    for img in imgs:
   1.363 +        zf.write(img, os.path.basename(img))
   1.364 +    zf.close()
   1.365  
   1.366  
   1.367 -## Use template file
   1.368 -TMPLFILE = "emin-default.html.templ"
   1.369 -logging.info("Using index template file %s" % TMPLFILE)
   1.370 -tf = open(TMPLFILE, "r")
   1.371 -tmplstr = tf.read()
   1.372 -tf.close()
   1.373 +## Copy Lightbox stuff into place
   1.374 +#if opts.USE_JS:
   1.375 +#    from zipfile import ZipFile
   1.376 +#    zf = ZipFile(os.path.join(opts.OUTDIR, "lightbox.zip"), "r")
   1.377 +#    for img in imgs:
   1.378 +#        zf.write(img, os.path.basename(img))
   1.379 +#    zf.close()
   1.380 +   
   1.381 +
   1.382 +## Default template
   1.383 +tmplstr = \
   1.384 +"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   1.385 +        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   1.386 +<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
   1.387 +  <head>
   1.388 +    #set title = $PAGETITLE + " (page %s)" % $PAGENUM
   1.389 +    <title>$title</title>
   1.390 +    <style>
   1.391 +      img { border:0; margin:5px; }
   1.392 +      body { padding:1em; background:white; font-family:sans-serif; }
   1.393 +      h1 { font-family:sans-serif; }
   1.394 +    </style>
   1.395 +    #if $OPTS.USE_JS:
   1.396 +    <link rel="stylesheet" href="lightbox/css/lightbox.css" type="text/css" media="screen" />	
   1.397 +    <script src="lightbox/js/prototype.js" type="text/javascript"></script>
   1.398 +    <script src="lightbox/js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
   1.399 +    <script src="lightbox/js/lightbox.js" type="text/javascript"></script>
   1.400 +    #end if
   1.401 +  </head>
   1.402 +  <body>
   1.403 +    <h1>$PAGETITLE</h1>
   1.404 +    #if $NUM_PAGES > 1
   1.405 +    <div class="pagelinks">Pages: $LINKSTR</div>
   1.406 +    #end if
   1.407 +
   1.408 +    <table>
   1.409 +    <tr>
   1.410 +    #set jsrel = ''
   1.411 +    #if $OPTS.USE_JS:
   1.412 +    #set jsrel = 'rel="lightbox[emin]"'
   1.413 +    #end if
   1.414 +    #for n, thumb in enumerate($PAGEPICS)
   1.415 +      #if $n % $NUM_COLS == 0 and $n not in (0, len($PAGEPICS)-1)
   1.416 +      <tr/><tr>
   1.417 +      #end if
   1.418 +      #set info = $PICINFO[$thumb]
   1.419 +      <td>
   1.420 +        <a href="$info.relpath" $jsrel>
   1.421 +          <img alt="$thumb" src="$info.relthumbpath" style="border:0;" width="$info.thumbx" height="$info.thumby" />
   1.422 +        </a><br/>
   1.423 +        #for fmt, name in $info.versions.iteritems()
   1.424 +        <a href="$name">$fmt.lower()</a>
   1.425 +        #end for
   1.426 +      </td>
   1.427 +    #end for
   1.428 +    </tr>
   1.429 +    </table>
   1.430 +
   1.431 +    #if $NUM_PAGES > 1
   1.432 +    <div class="pagelinks">Pages: $LINKSTR</div>
   1.433 +    #end if
   1.434 +
   1.435 +    #if $OPTS.WRITE_ZIPFILE:
   1.436 +    <p>All zipped up: <a href="$ZIPFILE">$ZIPFILE</a></p>
   1.437 +    #end if
   1.438 +  </body>
   1.439 +</html>
   1.440 +"""
   1.441 +
   1.442 +
   1.443 +## Override default template with a template file
   1.444 +if opts.TEMPLATE is not None:
   1.445 +    logging.info("Using index template file %s" % opts.TEMPLATE)
   1.446 +    tf = open(opts.TEMPLATE, "r")
   1.447 +    tmplstr = tf.read()
   1.448 +    tf.close()
   1.449  
   1.450  
   1.451  ## Make each index page
   1.452 @@ -283,44 +414,57 @@
   1.453      PAGENUM = n + 1
   1.454  
   1.455      ## Choose and open page file
   1.456 -    PAGEFILE = getPageFilename(PAGENUM)
   1.457 +    PAGEFILE = getPageFilename(PAGENUM) 
   1.458 +    PAGEPATH = os.path.join(opts.OUTDIR, PAGEFILE)
   1.459  
   1.460      ## Write the title
   1.461 -    PAGETITLE = opts.TITLE
   1.462 -    if PAGENUM > 0:
   1.463 -        PAGETITLE += " (page %s)" % PAGENUM
   1.464 +    PAGETITLE = opts.TITLE or os.path.basename(opts.SRCDIR)
   1.465      
   1.466      ## Write the linked page list
   1.467      LINKSTR = mkPageLinkStr(PAGENUM)
   1.468      
   1.469 -    ## Make thumbnails if needed and write the image HTML
   1.470 -    ## Display in table
   1.471 +    ## Work out the picture offsets for this page
   1.472      pics_start = n * NUM_PER_PAGE
   1.473      pics_end = (n+1) * NUM_PER_PAGE - 1
   1.474 -    if pics_end >= len(pics):
   1.475 -        pics_end = len(pics) - 1
   1.476 +    if pics_end >= len(imgs):
   1.477 +        pics_end = len(imgs) - 1
   1.478  
   1.479 -    PAGEPICS = pics[pics_start: pics_end]
   1.480 -    PAGEPICNUMS = range(len(pics))
   1.481 -    PAGETHUMBS = [t.path for t in thumbsinfo.keys()[pics_start : pics_end]]
   1.482 -    PAGETHUMBDIMS = [t.size for t in thumbsinfo.keys()[pics_start : pics_end]]
   1.483 +    PAGEPICS = sorted(imgsinfo.keys())[pics_start: pics_end]
   1.484 +    PAGEPICNUMS = range(len(PAGEPICS))
   1.485 +    relthumbdir = opts.THUMBDIR
   1.486 +    #relthumbdir = os.path.relpath(THUMBDIR, OUTDIR)
   1.487 +    reloutdir = "."
   1.488 +    for k in imgsinfo.keys():
   1.489 +        imgsinfo[k].relthumbpath = os.path.normpath(os.path.join(relthumbdir, imgsinfo[k].thumbname))
   1.490 +        imgsinfo[k].relpath = os.path.normpath(os.path.join(reloutdir, imgsinfo[k].name))
   1.491 +    PICINFO = imgsinfo
   1.492 +#     THUMBNAMES = [t.name for t in thumbsinfo.values()[pics_start : pics_end]]
   1.493 +#     print THUMBNAMES
   1.494 +#     THUMBPATHS = [os.path.join(relthumbdir, name) for name in THUMBNAMES]
   1.495 +#     print THUMBPATHS
   1.496 +#     THUMBDIMS = [t.size for t in thumbsinfo.values()[pics_start : pics_end]]
   1.497  
   1.498 -    logging.info("Writing to index file %s" % PAGEFILE)
   1.499 -    f = open(PAGEFILE, "w")
   1.500 +    logging.info("Writing to index file %s" % PAGEPATH)
   1.501 +    f = open(PAGEPATH, "w")
   1.502      tdict = {}
   1.503      tdict["NUM_PAGES"] = NUM_PAGES
   1.504 +    tdict["NUM_PER_PAGE"] = NUM_PER_PAGE
   1.505 +    tdict["NUM_ROWS"] = opts.NUM_ROWS
   1.506 +    tdict["NUM_COLS"] = opts.NUM_COLS
   1.507      tdict["PAGEPICS"] = PAGEPICS
   1.508      tdict["PAGENUM"] = PAGENUM
   1.509 -    tdict["PAGENUM"] = PAGENUM
   1.510      tdict["PAGETITLE"] = PAGETITLE
   1.511      tdict["LINKSTR"] = LINKSTR
   1.512 -    tdict["PAGEPICS"] = PAGEPICS
   1.513      tdict["PAGEPICNUMS"] = PAGEPICNUMS
   1.514 -    tdict["PAGETHUMBS"] = PAGETHUMBS
   1.515 -    tdict["PAGETHUMBDIMS"] = PAGETHUMBDIMS
   1.516 +    tdict["PICINFO"] = imgsinfo
   1.517 +#     tdict["THUMBS"] = thumbsinfo
   1.518 +#     tdict["THUMBNAMES"] = THUMBNAMES
   1.519 +#     tdict["THUMBPATHS"] = THUMBPATHS
   1.520 +#     tdict["THUMBDIMS"] = THUMBDIMS
   1.521      tdict["ZIPFILE"] = ZIPFILE
   1.522      tdict["OPTS"] = opts
   1.523      indexstr = Template(tmplstr, searchList=[tdict])
   1.524 +    #print indexstr
   1.525      f.write(str(indexstr))
   1.526      f.close()
   1.527  
     2.1 Binary file lightbox.zip has changed

mercurial