From b666e5959e3eb170e57bb1937f9589cfbe7c0ae4 Mon Sep 17 00:00:00 2001 From: Masamichi Hosoda Date: Mon, 25 May 2015 23:41:16 +0900 Subject: [PATCH] Issue 4420: Add Netpbm messages to verbose output 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 | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/scm/ps-to-png.scm b/scm/ps-to-png.scm index 9c977b6463..93bce270ed 100644 --- a/scm/ps-to-png.scm +++ b/scm/ps-to-png.scm @@ -48,20 +48,25 @@ (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) @@ -152,5 +157,5 @@ (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))) -- 2.39.2