Re: ImageMagick

"Jürgen Spitzmüller" <[email protected]> Fri, 15 May 2026 12:54:32 +0200
Newsgroups gmane.editors.lyx.devel
Message-ID <[email protected]>
Am Freitag, dem 15.05.2026 um 12:38 +0200 schrieb Pavel Sanda:
> My worry is about the document containing png figure being exported
> to pdf. I didn't inspect the current code, but assume that the
> conversion of the figure is done by IM. Adding explicit img2pdf
> might overload it and create slightly different output for users
> with normally functional IM.
> 
> If my assumption is not correct feel free to dismiss my previous
> email...

I didn't check that, but meanwhile it turned out that img2pdf is
probably not very reliable. The tests regularly stall.

I have tried now to use inkscape for png->eps and this works better.

See attached patch.

-- 
Jürgen

-- 
lyx-devel mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-devel
c2.diff (text/x-patch, 2.2 KB)
diff --git a/lib/configure.py b/lib/configure.py
index 8561a51b7f..d2df759981 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1247,12 +1247,35 @@ 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 eps to png
+    _, cmd = checkProg('a PNG -> EPS converter', ['magick', 'convert'])
+    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)
+        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.')
+            #try inkscape instead.
+            if inkscape_stable:
+                checkProg('a PNG -> EPS converter', [inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
+                    rc_entry = [ r'\converter png        eps        "%%"	""'])
+            else:
+                checkProg('a 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