summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès2008-02-08 11:25:35 +0100
committerLudovic Courtès2008-02-08 11:25:35 +0100
commitf532bd147bf93121c179179be4205bab5ba955ae (patch)
tree27f74b94aa93eaf2efee15a5216778a595ecc968
parentb0727a8288ba6518920f411e76b9148731b8c2bd (diff)
downloadskribilo-f532bd147bf93121c179179be4205bab5ba955ae.tar.gz
skribilo-f532bd147bf93121c179179be4205bab5ba955ae.tar.lz
skribilo-f532bd147bf93121c179179be4205bab5ba955ae.zip
configure: Look for `convert' and `fig2dev'.
* NEWS, README: Update. * configure.ac: Look for `convert' and `fig2dev'. Produce `src/guile/skribilo/utils/images.scm'. * src/guile/skribilo/utils/images.scm.in: Use Autoconf substitution.
-rw-r--r--NEWS1
-rw-r--r--README8
-rw-r--r--configure.ac10
-rw-r--r--src/guile/skribilo/utils/images.scm8
-rw-r--r--src/guile/skribilo/utils/images.scm.in102
5 files changed, 126 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 9641054..b47a8c3 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Copyright (C) 2005, 2006, 2007, 2008 Ludovic Courtès <ludo@gnu.org>
New in Skribilo 0.9.1
+* Improved `configure' diagnostics
* Various documentation fixes and improvements
diff --git a/README b/README
index f4fe5a4..91a37f7 100644
--- a/README
+++ b/README
@@ -35,6 +35,9 @@ You need at least:
* Guile-Reader >= 0.3
http://www.nongnu.org/guile-reader/
+ * ImageMagick, used to convert images from one format to another
+ http://imagemagick.org/
+
Optionally, you may want to install one of the following document layout
programs to produce PS/PDF files:
@@ -52,6 +55,11 @@ Optionally, to produce pie charts, you may want to use:
* Ploticus
http://ploticus.sourceforge.net/
+To convert images in the `fig' format:
+
+ * Xfig, Transfig
+ http://xfig.org/
+
This is it!
diff --git a/configure.ac b/configure.ac
index a2de438..2cb6833 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,15 @@ GUILE_MODULE_REQUIRED([srfi srfi-35])
GUILE_MODULE_REQUIRED([srfi srfi-37])
+# Look for `convert', from ImageMagick.
+AC_PATH_PROG([CONVERT], [convert])
+if test "x$CONVERT" == "x"; then
+ AC_MSG_ERROR([The `convert' program was not found. Please install ImageMagick.])
+fi
+
+# Look for `fig2dev', from Xfig/Transfig.
+AC_PATH_PROG([FIG2DEV], [fig2dev], [fig2dev])
+
# Look for a suitable version of Lout.
LOUT_PROGRAM([LOUT_REQUIRED_PACKAGE([math])])
@@ -85,6 +94,7 @@ AC_OUTPUT([Makefile
src/guile/Makefile
src/guile/skribilo/Makefile
src/guile/skribilo/utils/Makefile
+ src/guile/skribilo/utils/images.scm
src/guile/skribilo/engine/Makefile
src/guile/skribilo/reader/Makefile
src/guile/skribilo/package/Makefile
diff --git a/src/guile/skribilo/utils/images.scm b/src/guile/skribilo/utils/images.scm
index 29535a3..037e79e 100644
--- a/src/guile/skribilo/utils/images.scm
+++ b/src/guile/skribilo/utils/images.scm
@@ -1,6 +1,6 @@
;;; images.scm -- Images handling utilities.
;;;
-;;; Copyright 2005, 2006, 2007 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright 2005, 2006, 2007, 2008 Ludovic Courtès <ludo@gnu.org>
;;; Copyright 2003, 2004 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;
;;;
@@ -40,7 +40,7 @@
;;; Code:
(define *fig-convert-program* (make-parameter "fig2dev -L"))
-(define *generic-convert-program* (make-parameter "convert"))
+(define *generic-convert-program* (make-parameter "/usr/bin/convert"))
(define (builtin-convert-image from fmt dir)
(let* ((s (file-suffix from))
@@ -95,6 +95,8 @@
(loop (cdr fmts)))))))))))
-;;; arch-tag: a1992fa8-6073-4cd7-a018-80e2cc8d537c
+;;; Local Variables:
+;;; coding: latin-1
+;;; End:
;;; images.scm ends here
diff --git a/src/guile/skribilo/utils/images.scm.in b/src/guile/skribilo/utils/images.scm.in
new file mode 100644
index 0000000..dd0c3a0
--- /dev/null
+++ b/src/guile/skribilo/utils/images.scm.in
@@ -0,0 +1,102 @@
+;;; images.scm -- Images handling utilities.
+;;;
+;;; Copyright 2005, 2006, 2007, 2008 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright 2003, 2004 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
+;;;
+;;;
+;;; This program is free software; you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 2 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program; if not, write to the Free Software
+;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+;;; USA.
+
+(define-module (skribilo utils images)
+ :export (convert-image
+ *fig-convert-program* *generic-convert-program*)
+
+ :autoload (skribilo utils files) (file-suffix file-prefix)
+ :autoload (skribilo parameters) (*image-path* *verbose*)
+ :autoload (skribilo condition) (&file-search-error)
+ :autoload (srfi srfi-34) (raise)
+ :use-module (srfi srfi-35)
+ :use-module (srfi srfi-39))
+
+;;; Author: Erick Gallesio, Ludovic Courtès
+;;;
+;;; Commentary:
+;;;
+;;; This module provides convenience functions to handle image files, notably
+;;; for format conversion via ImageMagick's `convert'.
+;;;
+;;; Code:
+
+(define *fig-convert-program* (make-parameter "@FIG2DEV@ -L"))
+(define *generic-convert-program* (make-parameter "@CONVERT@"))
+
+(define (builtin-convert-image from fmt dir)
+ (let* ((s (file-suffix from))
+ (f (string-append (file-prefix (basename from)) "." fmt))
+ (to (string-append dir "/" f))) ;; FIXME:
+ (cond
+ ((string=? s fmt)
+ to)
+ ((file-exists? to)
+ to)
+ (else
+ (let ((c (if (string=? s "fig")
+ (string-append (*fig-convert-program*) " "
+ fmt " " from " > " to)
+ (string-append (*generic-convert-program*) " "
+ from " " to))))
+ (cond
+ ((> (*verbose*) 1)
+ (format (current-error-port) " [converting image: ~S (~S)]~%" from c))
+ ((> (*verbose*) 0)
+ (format (current-error-port) " [converting image: ~S]~%" from)))
+ (and (zero? (system c))
+ to))))))
+
+(define (convert-image file formats)
+ (let ((path (search-path (*image-path*) file)))
+ (if (not path)
+ (raise (condition (&file-search-error (file-name file)
+ (path (*image-path*)))))
+ (let ((suf (file-suffix file)))
+ (if (member suf formats)
+ (let* ((dir (if (string? (*destination-file*))
+ (dirname (*destination-file*))
+ #f)))
+ (if dir
+ (let* ((dest (basename path))
+ (dest-path (string-append dir "/" dest)))
+ (if (and (not (string=? path dest-path))
+ (not (file-exists? dest-path)))
+ (copy-file path dest-path))
+ dest)
+ path))
+ (let loop ((fmts formats))
+ (if (null? fmts)
+ #f
+ (let* ((dir (if (string? (*destination-file*))
+ (dirname (*destination-file*))
+ "."))
+ (p (builtin-convert-image path (car fmts) dir)))
+ (if (string? p)
+ p
+ (loop (cdr fmts)))))))))))
+
+
+;;; Local Variables:
+;;; coding: latin-1
+;;; End:
+
+;;; images.scm ends here