On Mon, Feb 05, 2007 at 02:02:07PM +0100, Jean-Marc Lasgouttes wrote:

> Enrico> In order to establish whether convert supports the -define
> Enrico> option, I don't check for its version number but directly try
> Enrico> to perform the conversion. 
> 
> Here I can do I do 
> 
> fantomas: convert -define foo:bar
> convert: MissingAnImageFilename.
> fantomas: convert -definexxx foo:bar
> convert: UnrecognizedOption.
> 
> Can't you just invoke convert with the -define option and see what
> message error is returned?

Yes, this is another possibility. Incidentally, I discovered that
cmdOutput only returns the stdout of a command, discarding stderr,
so I used commands.getoutput which returns both. I think that cmdOutput
could also be rewritten using commands.getoutput. What do you think?
I also tested the attached patch with a native Windows python.

-- 
Enrico
Index: lib/configure.py
===================================================================
--- lib/configure.py    (revision 17053)
+++ lib/configure.py    (working copy)
@@ -1,4 +1,5 @@
 #! /usr/bin/env python
+# -*- coding: utf-8 -*-
 #
 # file configure.py
 # This file is part of LyX, the document processor.
@@ -7,7 +8,7 @@
 # \author Bo Peng
 # Full author contact details are available in file CREDITS.
 
-import sys, os, re, shutil, glob
+import sys, os, re, shutil, glob, commands
 
 
 class Tee:
@@ -405,6 +406,13 @@ def checkConverterEntries():
     checkProg('an EPS -> PDF converter', ['epstopdf'],
         rc_entry = [ r'\converter eps        pdf        "epstopdf 
--outfile=$$o $$i"   ""', ''])
     #
+    path, convert = checkProg('a PDF -> PNG converter', ['convert'])
+    if convert != '':
+        # check whether convert supports the -define option
+        conv_opts = "-define pdf:use-cropbox=true -depth 8"
+        if not 'Unrecognized' in commands.getoutput('convert ' + conv_opts):
+            addToRC(r'\converter pdf        png        "convert %s pdf:$$i 
png:$$o"    ""' % conv_opts)
+    #
     checkProg('a Grace -> Image converter', ['gracebat'],
         rc_entry = [
             r'''\converter agr        eps        "gracebat -hardcopy 
-printfile $$o -hdevice EPS $$i 2>/dev/null"      ""

Reply via email to