lilypond-devel
[Top][All Lists]
Advanced

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

Re: output-distance: create PNG files in batch (issue 567530052 by addre


From: hanwenn
Subject: Re: output-distance: create PNG files in batch (issue 567530052 by address@hidden)
Date: Sat, 02 May 2020 14:47:49 -0700

Reviewers: hahnjo,


https://codereview.appspot.com/567530052/diff/549980043/scripts/build/output-distance.py
File scripts/build/output-distance.py (right):

https://codereview.appspot.com/567530052/diff/549980043/scripts/build/output-distance.py#newcode739
scripts/build/output-distance.py:739: ' -sDEVICE=png16m'
On 2020/05/02 15:07:20, hahnjo wrote:
> you might want to remove this and instead use -dNODISPLAY; interesting
that
> png16m doesn't force you to specify an output file, pdfwrite does...
> 
> and I'd reorder the invocation to have the "generic" options -q
-dNOPAUSE
> -dNOSAFER -dEPSCrop at the beginning; IMHO this makes it much easier
to reason
> about the invocation

Done.

Description:
output-distance: create PNG files in batch

Please review this at https://codereview.appspot.com/567530052/

Affected files (+26, -23 lines):
  M scripts/build/output-distance.py


Index: scripts/build/output-distance.py
diff --git a/scripts/build/output-distance.py b/scripts/build/output-distance.py
index 
2a48522d50ef508eece521184c757763763f387d..57455e9d2aa8f896f7aa7133650c3e7f9c86c112
 100644
--- a/scripts/build/output-distance.py
+++ b/scripts/build/output-distance.py
@@ -720,32 +720,35 @@ class SignatureFileLink (FileLink):
             log_verbose ('entering directory %s' % abs_dir)
             os.chdir (dir)
 
-            for f in glob.glob (base):
-                outfile = (out_dir + '/' + f).replace ('.eps', '.png')
-                data_option = ''
-                if options.local_data_dir:
-                    data_option = 
('-slilypond-datadir=%s/share/lilypond/current '
+            data_option = ''
+            if options.local_data_dir:
+                data_option = ('-slilypond-datadir=%s/share/lilypond/current '
                                    % abs_dir)
 
-                cmd = ('gs'
-                       ' -sDEVICE=png16m'
-                       ' -dGraphicsAlphaBits=4'
-                       ' -dTextAlphaBits=4'
-                       ' %(data_option)s'
-                       ' -r101'
-                       ' -dAutoRotatePages=/None'
-                       ' -dPrinted=false'
-                       ' -sOutputFile=%(outfile)s'
-                       ' -dNOSAFER'
-                       ' -dEPSCrop'
-                       ' -q'
-                       ' -dNOPAUSE'
-                       ' %(f)s'
-                       ' -c quit') % locals ()
-
+            driver = open('batch.ps', 'w')
+            for f in glob.glob (base):
+                outfile = (out_dir + '/' + f).replace ('.eps', '.png')
+                driver.write('''
+                mark /OutputFile (%s)
+                (png16m) finddevice putdeviceprops setdevice
+                (%s) run
+                ''' % (outfile, f))
                 files_created[oldnew].append (outfile)
-                log_terse ('creating %s' % outfile)
-                system (cmd)
+            driver.close()
+            cmd = ('gs '
+                   ' -sDEVICE=png16m'
+                   ' -dGraphicsAlphaBits=4'
+                   ' -dTextAlphaBits=4'
+                   ' -r101'
+                   ' -dAutoRotatePages=/None'
+                   ' -dPrinted=false'
+                   ' -dNOSAFER'
+                   ' -dEPSCrop'
+                   ' -q'
+                   ' -dNOPAUSE'
+                   ' batch.ps'
+                   ' -c quit')
+            system (cmd)
 
             log_verbose ('leaving directory %s' % abs_dir)
             os.chdir (cur_dir)





reply via email to

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