[LyX/2.5.x] Use inkscape as fallback png->eps converter
Juergen Spitzmueller
spitz at lyx.org
Sat May 16 06:20:56 UTC 2026
commit 200493042899d9c7f5b7dd4c4366573e9b31e389
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Fri May 15 14:38:30 2026 +0200
Use inkscape as fallback png->eps converter
if ImageMagick is not available or IM policy does not allow for this
conversion
(cherry picked from commit 5aefad462b850708012eea42cff0145452a1cb6b)
---
lib/configure.py | 29 ++++++++++++++++++++++++++++-
status.25x | 2 ++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/lib/configure.py b/lib/configure.py
index 28133a9a6a..9aea675a5a 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1168,12 +1168,39 @@ def checkConverterEntries():
removeFiles(['mock.eps'])
#needs empty record otherwise default converter will be issued
addToRC(r'''\converter eps png "" ""
-\converter png eps "" ""
\converter jpg tiff "convert $$i $$o" ""
\converter png tiff "convert $$i $$o" ""''')
logger.info('ImageMagick seems to ban conversions from EPS. Disabling direct EPS->PNG.')
pdftopng.append('pdftoppm -r 72 -png -singlefile $$i > $$o')
#
+ # Same for png to eps
+ _, cmd = checkProg('a PNG -> EPS converter', ['magick', 'convert'])
+ have_png2eps = False
+ if cmd:
+ from PIL import Image
+ img = Image.new('RGB', (5, 5))
+ img.save("mock.png", "PNG")
+ try:
+ subprocess.check_call([cmd, "mock.png", "mock.eps"])
+ removeFiles(['mock.eps', 'mock.png'])
+ rc_entry = r'\converter png eps "%s $$i[0] $$o" ""'
+ addToRC(rc_entry % cmd)
+ have_png2eps = True
+ except:
+ removeFiles(['mock.png'])
+ #needs empty record otherwise default converter will be issued
+ addToRC(r'''\converter png eps "" ""''')
+ logger.info('ImageMagick seems to ban conversions to EPS. Disabling direct PNG->EPS.')
+
+ if not have_png2eps:
+ #try inkscape instead.
+ if inkscape_stable:
+ checkProg('an alternative PNG -> EPS converter', [inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
+ rc_entry = [ r'\converter png eps "%%" ""'])
+ else:
+ checkProg('an alternative PNG -> EPS converter', [inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'],
+ rc_entry = [ r'\converter png eps "%%" ""'])
+ #
# PDF -> PNG: sips (mac), IM convert (windows, linux), pdftoppm (linux with IM ban)
# sips:Define a converter from pdf6 to png for Macs where pdftops is missing.
# The converter utility sips allows to force the dimensions of the resulting
diff --git a/status.25x b/status.25x
index 9d5ffaa4e4..a8152dd57e 100644
--- a/status.25x
+++ b/status.25x
@@ -43,6 +43,8 @@ What's new
* BUILD/INSTALLATION
+- Use inkscape as fallback png->eps converter if ImageMagick is not
+ available or IM policy does not allow for png->eps conversion.
More information about the lyx-cvs
mailing list