]> git.donarmstrong.com Git - lilypond.git/commitdiff
use optargs for ps-to-png , and support different pixmap types.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 11 Dec 2006 22:52:00 +0000 (23:52 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 11 Dec 2006 22:55:36 +0000 (23:55 +0100)
Eg. use -dpixmap-type=jpeg.

scm/backend-library.scm
scm/lily.scm
scm/ps-to-png.scm

index 07ab29ecd70880bc94dd5fdaa08c011ae7f29ff0..5258bcf516249978a06d25166fa46b6b50964dc4 100644 (file)
        (rename-page-1 #f))
 
     (ly:message (_ "Converting to ~a...") "PNG")
-    (make-ps-images name resolution paper-width paper-height rename-page-1 verbose
-                   (ly:get-option 'anti-alias-factor))
+
+    (make-ps-images name
+                   #:resolution resolution
+                   #:page-width  paper-width
+                   #:page-height paper-height
+                   #:rename-page-1 rename-page-1
+                   #:be-verbose verbose
+                   #:anti-alias-factor (ly:get-option 'anti-alias-factor)
+                   #:pixmap-format (ly:get-option 'pixmap-format) 
+                   )
+    
     (ly:progress "\n")))
 
 (define-public (postprocess-output paper-book module filename formats)
index 868998ffc53dd4bb4bf45416ce4652752f3593c7..6a0a712178173ead20f3edf6c7198596ad2e14bc 100644 (file)
@@ -47,6 +47,7 @@ similar to chord syntax")
                           "experimental mechanism for remembering tweaks")
              (point-and-click #t "use point & click")
              (paper-size "a4" "the default paper size")
+             (pixmap-format "png16m" "GS format to use for pixel images")
              (protected-scheme-parsing #t "continue when finding errors in inline
 scheme are caught in the parser. If off, halt 
 on errors, and print a stack trace.")
index d76f926a90203b02d006a082d99d25f8f2190c9d..2e124ae5acd4915d9beb404981f13d14955297cf 100644 (file)
        0)))
 
 (define-public (make-ps-images ps-name . rest)
-  (let-optional
-   rest ((resolution 90)
-        page-width
-        page-height
-        (rename-page-1? #f)
-        (verbose? #f)
-        (aa-factor 1) 
-        )
-
-   (let* ((base (basename (re-sub "[.]e?ps" "" ps-name)))
-         (png1 (string-append base ".png"))
-         (pngn (string-append base "-page%d.png"))
+  (let-keywords*
+   rest #f
+     ((resolution 90)
+      (page-width  100)
+      (page-height 100)
+      (rename-page-1 #f)
+      (be-verbose #f)
+      (pixmap-format 'png16m)
+      (anti-alias-factor 1))
+     
+   (let* (
+         (format-str (format "~a" pixmap-format))
+         (extension (cond
+                     ((string-contains format-str "png") "png")
+                     ((string-contains format-str "jpg") "jpeg")
+                     ((string-contains format-str "jpeg") "jpeg")
+                     (else
+                      (ly:error "Unknown pixmap format ~a" pixmap-format))))
+         (base (basename (re-sub "[.]e?ps" "" ps-name)))
+         (png1 (format "~a.~a" base pixmap-format))
+         (pngn (format  "~a-page%d.~a" base pixmap-format))
          (page-count (ps-page-count ps-name))
-         
          (multi-page? (> page-count 1))
          (output-file (if multi-page? pngn png1))
 
-         ;; png16m is because Lily produces color nowadays.
-         ;; can't use pngalpha device, since IE is broken.
-         ;;
          (gs-variable-options
           (if multi-page?
               (format #f "-dDEVICEWIDTHPOINTS=~,2f -dDEVICEHEIGHTPOINTS=~,2f" page-width page-height)
  -dGraphicsAlphaBits=4\
  -dTextAlphaBits=4\
  -dNOPAUSE\
- -sDEVICE=png16m\
+ -sDEVICE=~a\
  -sOutputFile=~S\
  -r~S\
  ~S\
  -c quit"
                       (search-gs)
-                      (if verbose? "" "-q")
+                      (if be-verbose "" "-q")
                       gs-variable-options
+                      pixmap-format
                       output-file 
-                      (* aa-factor resolution) ps-name))
+                      (* anti-alias-factor resolution) ps-name))
          (status 0)
          (files '()))
 
           (set! cmd (re-sub "=" "#" cmd))
           (set! cmd (re-sub "-dSAFER " "" cmd))))
 
-     (set! status (my-system verbose? #f cmd))
+     (set! status (my-system be-verbose #f cmd))
 
      (set! files
           (if multi-page?
           (map delete-file files)
           (exit 1)))
 
-     (if (and rename-page-1? multi-page?)
+     (if (and rename-page-1 multi-page?)
         (begin
           (rename-file (re-sub "%d" "1" pngn) png1)
           (set! files
                       (cdr files)))
           ))
 
-     (if (not (= 1 aa-factor))
-        (for-each  (lambda (f) (scale-down-image verbose? aa-factor f))
+     (if (not (= 1 anti-alias-factor))
+        (for-each  (lambda (f) (scale-down-image be-verbose anti-alias-factor f))
                    files))
 
      files)))