From b343446bd42ccba62ecb0664c757c10c03c545cd Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sat, 31 Mar 2007 18:21:54 +0000 Subject: [PATCH] Fix bug 3400 * lib/scripts/convertDefault.py: Use the cropbox option when the source format is pdf and convert supports it. * lib/configure.py: Don't define a PDF->PNG converter in order to avoid the EPS->PDF->PNG route when converting EPS to a loadable format. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17668 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/configure.py | 7 ------- lib/scripts/convertDefault.py | 13 ++++++++++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/configure.py b/lib/configure.py index fc9696f9a0..b2b2f37fe6 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -409,13 +409,6 @@ 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 cmdOutput('convert ' + conv_opts + ' 2>&1'): - addToRC(r'\converter pdf png "convert %s pdf:$$i png:$$o" ""' % conv_opts) - # # no agr -> pdf converter, since the pdf library used by gracebat is not # free software and therefore not compiled in in many installations. # Fortunately, this is not a big problem, because we will use epstopdf to diff --git a/lib/scripts/convertDefault.py b/lib/scripts/convertDefault.py index 075fb4aa03..1806b2ecc5 100644 --- a/lib/scripts/convertDefault.py +++ b/lib/scripts/convertDefault.py @@ -18,7 +18,18 @@ # converts an image from $1 to $2 format import os, sys -if os.system(r'convert -depth 8 "%s" "%s"' % (sys.argv[1], sys.argv[2])) != 0: + +opts = "-depth 8" +# for pdf source formats, check whether convert supports the -define option +if sys.argv[1][:4] == 'pdf:': + defopt = "-define pdf:use-cropbox=true" + fout = os.popen('convert ' + defopt + ' 2>&1') + output = fout.read() + fout.close() + if not 'unrecognized' in output.lower(): + opts = defopt + ' ' + opts + +if os.system(r'convert %s "%s" "%s"' % (opts, sys.argv[1], sys.argv[2])) != 0: print >> sys.stderr, sys.argv[0], 'ERROR' print >> sys.stderr, 'Execution of "convert" failed.' sys.exit(1)