TransWikia.com

Lyx, Error Converting to Loadable Format for PDFs

TeX - LaTeX Asked by Veridian on July 14, 2021

I’m using Lyx 2.2 on windows 10 and ghostscript 9.19.
When I have pdfs images embedded in my document they don’t display in the Lyx window (they appear in the final PDF however).

Where the images should preview it just says, “Error converting to loadable format”.

I’ve tried looking at the latex log, but I can’t seem to gain any insight as to how to resolve this issue.
I’ve also tried searching many forums online but they all seem to point to updating ghostscript, which doesn’t apply to me since I’m running the latest version.

15 Answers

Short answer: https://wiki.lyx.org/LyX/FiguresInLyX

Long answer:

To view a image on the LyX screen, it is required a compatible format with that XForms or Qt GUI libraries, namely bmp, gif, jpeg, pbm, pgm, ppm, tif, xbm or mng, png and xpm, respectively.

A message "Error converting to loadable format" mean that is not possible convert the image to PNG or any of these formats.

then you'll need to augment the list of known converters.

The link shows a detailed example of adding a converter. Pay attention that the converters are in the right path.

However,

If you see the "Error converting to loadable format" message only with PDF files and you've verified that you have the converter tools mentioned above, check which version of GhostScript you are using.

Version 8.7 of GhostScript has a known bug that prevents LyX from loading PDFs. Use the newest version. (The link above also explain a manual fix).

Correct answer by Fran on July 14, 2021

I'm using LyX 2.2.2 on Windows 7, and I have the same problem. After installing GhostScript 9.20, open LyX and click "Tools" -> "Reconfigure", finally restart LyX, and the problem is solved. I can see all PDF figures displayed in LyX. (However, the quality of the display is a little rough)

Answered by pig on July 14, 2021

I'm using Lyx 2.2 under macOS Sierra. In my case, the problem was the ImageMagick version (7), and its incompatibility issues with LyX conversion scripts, as mentioned here: https://www.mail-archive.com/[email protected]/msg194142.html.

I'm using brew, so I fixed this problem by removing imagemagic and installing the latest 6.x version: imagemagick@6 and then creating a symbolic link (in /usr/local/bin) pointing to /usr/local/Cellar/imagemagick@6/6.9.7-5/bin/convert .

brew uninstall imagemagick
brew install imagemagick@6
ln -s /usr/local/Cellar/imagemagick@6/6.9.7-9/bin/convert /usr/local/bin/convert

Hope it helps

Answered by Hector Cadavid on July 14, 2021

For me on OSX the problem was that I didn't have ImageMagick installed at all. I'm not sure when it was expected to be installed, but anyway. Just follow Hector's instructions:

brew install imagemagick@6
ln -s /usr/local/Cellar/imagemagick@6/6.9.7-9/bin/convert /usr/local/bin/convert

Answered by Timmmm on July 14, 2021

I had exactly the same problem for LyX 2.2, whereas previously LyX 2.1 worked fine. So what I did was moving the ghostscript folder and the imagemagick folder from LyX 2.1 to LyX 2.2, and it turned out that it is imagemagick that has something wrong.

Answered by Alan Wang on July 14, 2021

Windows usernames containing certain non-alphanumeric characters like umlauts can cause the described symptoms.

On my system (Windows 8.1, LyX 2.2.2, ghostscript 9.15) Windows accounts with umlauts in their usernames suffer the problem described by Veridian: Embedded PDF images are not displayed in LyX, stating "Error converting to loadable format", even though they are displayed in the final PDF. On the contrary, Windows accounts with alphanumeric usernames do not suffer this problem on my system. This also holds for newly created accounts.

For me the following workaround helped:

  • In LyX go to Tools > Preferences > Paths
  • Set Temporary Directory to C:UsersPublicAppDataLocalTemp
  • Make sure the path exists
  • Restart LyX

Answered by Dörrobst on July 14, 2021

Ok rather than fiddling around with ImageMagick and Ghostscript, we can rely on sips which is built in to OSX. It's what the official fix does.

  1. Go to Lyx->Preferences->File Handling->Converters.
  2. Change the From format: to PDF (graphics), the To format: to PNG and paste this in the Converter: box: sips --resampleWidth 800 --setProperty format png $$i --out $$o.
  3. Click Add. Yes this dialog is weird - you don't add an entry then configure it, you change the options and then click Add. Confusing.
  4. Click Save. DO NOT CLICK APPLY! For some reason it shows an empty window and crashes Lyx.

The resulting PDFs can be a bit low res. You can increase the 800 if you like.

This fix should already be in Lyx 2.2.4 or later I think.

Answered by Timmmm on July 14, 2021

For me, on Windos 10 the following solved the problem:

Answered by jossele on July 14, 2021

In /etc/ImageMagick-6/policy.xml, comment out the lines like

<policy domain="coder" rights="none" pattern="(...)" />

This introduces a slight security risk, which may be (it seems!) ignored on a desktop system.

Answered by Dmitry Zotikov on July 14, 2021

There is a non-obvious detail that can cause this error despite having setup a suitable converter.

So for example, following Fran's answer and the LyX wiki instructions:

https://wiki.lyx.org/LyX/FiguresInLyX

you decide to add a pdf to png converter. Since png is well supported and is among the GUI displayable formats, that is a reasonable choice.

Under linux you might decide to use:

pdftoppm -png -singlefile $$i $$o

which generates slightly smaller files than pdftocairo -png .... The difficulty is, the output file will be named outfile.png.png and LyX will be unable to find it, causing the error:

Error converting to loadable format

which leaves no real clue about what the problem is.

An easy way to fix this is to use the command:

pdftoppm -png -singlefile $$i > $$o

which generates outfile.png and LyX proceeds normally.

Another issue is the display resolution. Under the LyX options tab you may wish to set the display size to 75% or so - this does not affect the ultimate pdf size, but it makes it easier to see what you have inserted in the GUI, since you can see the whole image.

Answered by Better_Error_Messages_Please on July 14, 2021

I had a similar problem, and none of the existing solutions worked for me (updating Ghostscript, uninstalling/reinstalling things, making sure imagemagick was there, etc.). I finally managed to solve the problem, so I'm posting what worked for me here in case others run into the same problem. For the record, I'm running Windows 10 Home.

Essentially, the problem boiled down to the fact that imagemagick was looking for a 32-bit version of Ghostscript, when I had a 64-bit version installed. The simple solution was to download the most recent 32-bit version of Ghostscript, and install it to Program Files (x86)GPLGS. Problem solved.

I was able to diagnose this problem by navigating to the imagemagick directory (Program Files (x86)LyX x.ximagemagick), and running a test pdf-to-png conversion from the command line. So:

  • Put a PDF file of some kind (one containing just a simple image) in the imagemagick directory. Call this test.pdf or something.
  • Open a command prompt (you might have to run as administrator), and navigate to the imagemagick directory.
  • Run the command: magick convert test.pdf test.png

When I did this, I got an error message, the first bit of which suggested that it had tried and failed to run the Ghostscript executable in the target folder Program Files (x86)GPLGS. This folder didn't exist, because I had only a 64-bit version of Ghostscript installed (which was located in Program Filesgs). Getting the 32-bit version fixed the problem instantly.

Answered by CornerSolution on July 14, 2021

I had the same problem, and what worked for me is a variant of Dmitry Zotikov's solution : just commenting out some lines didn't do it for me (I've no clue why!). Instead, I just renamed this file : /etc/ImageMagick-6/policy.xml --> /etc/ImageMagick-6/old-policy.xml and now LyX handles pdf files nicely again.

Now, have I just created some horrible security liability for my home computer?

Answered by Lorenzo Ramero on July 14, 2021

It seems that Catalina breaks ImageMagick+Lyx again... Although "convert" of ImageMagick works alone in the terminal, but it does not work on Lyx.

The solution is to find an alternative converter. After a few tries, I found two.

  1. Inkscape command-line version (need to install with Macports), then put inkscape $$i -e $$o in the converter for "EPS->PNG" in the LyX Preferences/File Handling
  2. GhostScript, using gs -dSAFER -dBATCH -dNOPAUSE -dEPSCrop -r100 -sDEVICE=pngalpha -sOutputFile=$$o $$i (r100 means DPI=100, you can change it)

gs is working better than Inkscape, as the latter is not handling well with some vector fonts.

Answered by CyTex on July 14, 2021

In case you are using Inkscape 1.0 or later (as of 05/04/2020) AND your source files are in SVG format (or another vector format handled by Inkscape on your system), you might actually suffer from another issue:

Inkscape changed some command line options frequently used by LyX. For example --without-gui must not longer be used, --export-png now is --export-filename etc.

Check out this Inkscape wiki page for a full list:
https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line#Deprecations_and_Replacements

Solutions:
a) reconfigure your Lyx (via menu Tools->Reconfigure) or
b) change all the inkscape commands manually (via menu Tools->Preferences, section File Handling->Converters) or
c) switch to another SVG conversion tool, e.g. librsvg

Answered by Ferdinand Rau on July 14, 2021

For what it's worth, in Ubuntu 20.04, the conversion went PDF -> EPS -> PNG.

Thus, the problem was the EPS -> PNG converter.

Per this answer, https://askubuntu.com/a/1210683/13169 , I changed the EPS -> PNG converter to:

gs -dSAFER -dEPSCrop -r600 -sDEVICE=pngalpha -o $$o $$i

Answered by fratrik on July 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP