gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] alph/alph/util psimages.py


From: Tuomas J. Lukka
Subject: [Gzz-commits] alph/alph/util psimages.py
Date: Tue, 22 Apr 2003 09:38:07 -0400

CVSROOT:        /cvsroot/alph
Module name:    alph
Changes by:     Tuomas J. Lukka <address@hidden>        03/04/22 09:38:07

Modified files:
        alph/util      : psimages.py 

Log message:
        Revamping for util

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/alph/util/psimages.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: alph/alph/util/psimages.py
diff -u alph/alph/util/psimages.py:1.1 alph/alph/util/psimages.py:1.2
--- alph/alph/util/psimages.py:1.1      Tue Apr 22 02:30:24 2003
+++ alph/alph/util/psimages.py  Tue Apr 22 09:38:07 2003
@@ -1,38 +1,35 @@
 # (c) Tuomas J. Lukka
 
-resolutions = [170, 50]
+import os
+import re
 
-pools = ["../../articlepool", "../../publicpool"]
-target = "../tmpimg"
+def convertFile(file, prefix, resolution):
+    """Convert a pageimagescroll to .png image files.
 
-do_all = 0
+    Parameters
 
-import os
-import re
+    file: The filename to convert
+    prefix: The prefix to use for the resulting files.
+           If prefix is "ab" then the files of 
+           a three-page .pdf will be
+           "ab1", "ab2" and "ab3". Note: 1-based.
+    """
+    print "Processing ",file
+    l = os.popen("file -i -b %(pool)s/%(file)s" % locals()).readlines()[0]
+    l = l.rstrip().lstrip()
+    print "'%(l)s'" % locals()
+
+    if l != "application/pdf" and l != "application/postscript":  
+       print "Unknown - ignoring"
+       return 0
+
+    cmdline = "gs -dBATCH -dNOPAUSE -sDEVICE=png256 -r%(res)s 
-sOutputFile=%(prefix)%%d %(file)s" % locals()
+    print "RUNNING ",cmdline
+    res = os.system(cmdline)
+    if res:
+       print "Error running gs",res
+       return 0
+
+    return 1
 
-def convertFile(block, toPrefix):
 
-def doPool(pool):
-    for file in os.listdir(pool):
-       if not file.startswith("data_"): continue
-       print "Processing ",file
-       l = os.popen("file -i -b %(pool)s/%(file)s" % locals()).readlines()[0]
-       l = l.rstrip().lstrip()
-       print "'%(l)s'" % locals()
-
-       if l != "application/pdf" and l != "application/postscript":  
-           print "Unknown - ignoring"
-           continue
-       block = "urn:x-storm:1.0:"+l+"," + file[5:]
-       block = block.replace("/", "__")
-       print "into ",block
-
-       for res in resolutions:
-           targetdir = target
-           cmdline = "gs -dBATCH -dNOPAUSE -sDEVICE=png256 -r%(res)s 
-sOutputFile=%(targetdir)s/%(block)s-%(res)s-%%d %(pool)s/%(file)s" % locals()
-           print "RUNNING ",cmdline
-           os.system(cmdline)
-
-if __name__ == '__main__':
-    for pool in pools: doPool(pool)
-       




reply via email to

[Prev in Thread] Current Thread [Next in Thread]