]> git.lyx.org Git - features.git/commitdiff
Detect ImageMagick 7
authorGeorg Baum <baum@lyx.org>
Tue, 10 May 2016 19:27:57 +0000 (21:27 +0200)
committerGeorg Baum <baum@lyx.org>
Tue, 10 May 2016 19:27:57 +0000 (21:27 +0200)
Imagemagick 7 does not have a convert command anymore, it is now called magick.
Joint work by Uwe and me.

lib/configure.py
lib/scripts/convertDefault.py

index cd2a0c5aa56a9c731935ac19402bbb4f8cba708c..5dcb29fa95c6e33b82710c44bf5799febb1ef1e7 100644 (file)
@@ -972,7 +972,7 @@ def checkConverterEntries():
     checkProg('an EPS -> PDF converter', ['epstopdf'],
         rc_entry = [ r'\converter eps        pdf6       "epstopdf --outfile=$$o $$i"   ""'])
     #
-    checkProg('an EPS -> PNG converter', ['convert $$i $$o'],
+    checkProg('an EPS -> PNG converter', ['magick $$i $$o', 'convert $$i $$o'],
         rc_entry = [ r'\converter eps        png        "%%"   ""'])
     #
     # no agr -> pdf6 converter, since the pdf library used by gracebat is not
index 40bc8b53c880e5f7cc50e936b3b8c0c5186058ac..16e8f190ee625e4db6f40fd6453c554fd63cd4d3 100644 (file)
@@ -20,9 +20,17 @@ import os, re, sys
 
 # We may need some extra options only supported by recent convert versions
 re_version = re.compile(r'^Version:.*ImageMagick\s*(\d*)\.(\d*)\.(\d*).*$')
-fout = os.popen('convert -version 2>&1')
+# imagemagick 7
+command = 'magick'
+fout = os.popen('magick -version 2>&1')
 output = fout.readline()
-fout.close()
+if fout.close() != None:
+    # older versions
+    # caution: windows has a convert.exe for converting file systems
+    command = 'convert'
+    fout = os.popen('convert -version 2>&1')
+    output = fout.readline()
+    fout.close()
 version = re_version.match(output)
 
 # Imagemagick by default
@@ -50,7 +58,7 @@ if sys.argv[1] == 'pdf' and (version >= 0x060206 or gm):
 if sys.argv[3] == 'ppm' and (version >= 0x060305 or gm):
     opts = opts + ' -flatten'
 
-if os.system(r'convert %s "%s" "%s"' % (opts, sys.argv[2], sys.argv[3] + ':' + sys.argv[4])) != 0:
+if os.system(r'%s %s "%s" "%s"' % (command, opts, sys.argv[2], sys.argv[3] + ':' + sys.argv[4])) != 0:
     print >> sys.stderr, sys.argv[0], 'ERROR'
-    print >> sys.stderr, 'Execution of "convert" failed.'
+    print >> sys.stderr, ('Execution of "%s" failed.' % command)
     sys.exit(1)