]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4420: Add Netpbm messages to verbose output
authorMasamichi Hosoda <trueroad@trueroad.jp>
Mon, 25 May 2015 14:41:16 +0000 (23:41 +0900)
committerMasamichi Hosoda <trueroad@trueroad.jp>
Sun, 31 May 2015 13:39:19 +0000 (22:39 +0900)
Messages of Netpbm commands
(pngtopnm, pnmscale, pnmtopng)
output to /dev/null.
So those messages couldn't be read.

This patch can add them to verbose output,
and they can be read.

scm/ps-to-png.scm

index 9c977b6463fd20d3a535ddcb353e567992736958..93bce270edefde72ad5b3e76c2a707a1cd19ebcb 100644 (file)
         (if exit-on-error (exit 1))))
   status)
 
-(define (scale-down-image be-verbose factor file)
-  (define (with-pbm)
-    (let* ((status 0)
-           (old (string-append file ".old")))
-
-      (rename-file file old)
-      (my-system
-       be-verbose #t
-       (format #f
-               "pngtopnm \"~a\" | pnmscale -reduce ~a 2>/dev/null | pnmtopng -compression 9 2>/dev/null > \"~a\""
-               old factor file))
-      (delete-file old)))
-
-  (with-pbm))
+(define (scale-down-image factor file)
+  (let* ((old (string-append file ".old"))
+         ;; Netpbm commands (pngtopnm, pnmscale, pnmtopng)
+         ;; outputs only standard output instead of a file.
+         ;; So we need pipe and redirection.
+         ;; However, ly:system can't handle them.
+         ;; Therefore, we use /bin/sh for handling them.
+         ;; FIXME: MinGW (except Cygwin) doesn't have /bin/sh.
+         (cmd
+          (list
+           "/bin/sh"
+           "-c"
+           (ly:format
+            "pngtopnm \"~a\" | pnmscale -reduce ~a | pnmtopng -compression 9 > \"~a\""
+            old factor file))))
+
+    (rename-file file old)
+    (ly:system cmd)
+    (delete-file old)))
 
 (define-public (ps-page-count ps-name)
   (let* ((byte-count 10240)
 
      (if (not (= 1 anti-alias-factor))
          (for-each
-          (lambda (f) (scale-down-image be-verbose anti-alias-factor f)) files))
+          (lambda (f) (scale-down-image anti-alias-factor f)) files))
      files)))