6

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.

  • 2
    Seem that pdf to png conversion for the preview fail for some reason. This has nothing to do with LaTeX, that do not need at all this conversion. Check the instalation and configuration of the converter (See Preferences > File Handling > Converters > "LyX Preview -> PNG". For Linux the default is python -tt $$s/scripts/lyxpreview2bitmap.py --png – Fran Aug 23 '16 at 23:45
  • @Fran, I'm using windows. this was the command there: python -tt $$s/scripts/lyxpreview2bitmap.py --png. – Veridian Aug 24 '16 at 16:32
  • Sorry, I noticed that is not the right converter. Probably is another convert or a bug of Ghostsript. I posted a general answer that should allow you to find the solution. – Fran Aug 25 '16 at 8:27
  • Looks like the next version of Lyx will use sips on OSX instead of ImageMagick. – Timmmm Jun 27 '17 at 9:11
  • On the recent linux desktops (May 2019), the issue is due to imagemagick policy update. It's a pity that Dmitry Zotikov comment (solution) is at the bottom of the page – Valery Pipin May 28 at 4:52

12 Answers 12

5

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).

  • 1
    Thanks for the answer. I've seen this answer posted online. As I said in my question, I'm using GhostScript 9.19, so that isn't the issue, and yes this is only happening with PDFs. – Veridian Aug 25 '16 at 16:39
  • @Veridian Then focus first on the converters and Lyx configuration. I would start by checking that ImageMagick is there and you can use the convert tool in a Windows console (the C\:> DOS prompt) to make manually some PDF to PNG conversion, for instance. Good luck! – Fran Aug 26 '16 at 2:17
3

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/lyx-devel@lists.lyx.org/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

  • Hmm this no longer seems to work. – Timmmm Jun 26 '17 at 16:13
2

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)

2

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.

2

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.

1

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
1

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.

1

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:\Users\Public\AppData\Local\Temp
  • Make sure the path exists
  • Restart LyX
  • Welcome to TeX.SX! Are you sure this is related to the problem? – TeXnician Apr 6 '17 at 15:20
  • @TeXnician Thanks! I edited my contribution and hope I made more clear, how it is related to the problem. – Dörrobst Apr 7 '17 at 15:38
1

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

1

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.

1

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.x\imagemagick\), 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 Files\gs\). Getting the 32-bit version fixed the problem instantly.

0

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?

New contributor
Lorenzo Ramero is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.