Hello!

I stumbled into problems previewing PDF graphics inside LyX. It would
give me the error "Unable to Convert to Loadable Format". That got me
some hits on Google, but the hits typically were from 2003, the issue
being about EPS files.

I investigated the message log, with only "Graphics conversion and
loading" enabled (full file see attachment). I found that the
conversion takes a very roundabout way, converting the PDF to PS, than
the PS to EPS and then EPS to PNG.

On examining the temporary directory, I found several PS files (and
some subdirectories unrelated to the image conversion), but no EPS or
PNG files. And indeed I found out that my system doesn't have a
"ps2eps" script on any of the "PATH prefix" folders. It has "ps2epsi"
though in MiKTeX!

My solution was to add a custom converter for PDF > PNG, simply using
LyX's own Image Magick "convert.exe":
   convert -density 96 pdf:$$i png:$$o

However, I'm now wondering...
1. Did I just overlook posts describing a solution?
2. Why does the default converter go such a roundabout way, when most
file formats work well with convert.exe directly?
3. Would ps2eps be included if I had chosen the combined LyX/MiKTeX
installer? CTAN says, that it is not part of MiKTeX (
http://www.ctan.org/pkg/ps2eps ).
3a. If yes, is there anywhere any indication that the combined
installer should be preferred?

kind regards, Klaus-Dieter


Platform Information:
- Windows 7
- MiKTeX 2.9, installed separately. Should be the newest version, so
not having ps2eps is surprising to me.
- Cygwin installed, but only "/bin" on the windows PATH.
13:54:40.281: 
(graphics-reload)C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\graphics\GraphicsCacheItem.cpp(408):
    Converting it to  format.
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\support\FileName.cpp(945):
 Recognised Fileformat: pdf
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\graphics\GraphicsCacheItem.cpp(378):
 [CacheItem::Impl::convertToDisplayFormat]
        Attempting to convert image file: 
E:/studium/diplomarbeit/labbook/3.Lyx/images/fe-100-s5-100gb-supercellsize-convergence.pdf
        with displayed filename: 
E:\studium\diplomarbeit\labbook\3.Lyx\images\fe-100-s5-100gb-supercellsize-convergence.pdf
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\support\FileName.cpp(945):
 Recognised Fileformat: pdf
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\graphics\GraphicsCacheItem.cpp(385):
 
        The file contains pdf format data.
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\graphics\GraphicsCacheItem.cpp(340):
 Unable to convert from pdf to bmp
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\graphics\GraphicsCacheItem.cpp(340):
 Unable to convert from pdf to pbm
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\graphics\GraphicsCacheItem.cpp(340):
 Unable to convert from pdf to pgm
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\graphics\GraphicsConverter.cpp(127):
 Converter c-tor:
        from_file:      
E:/studium/diplomarbeit/labbook/3.Lyx/images/fe-100-s5-100gb-supercellsize-convergence.pdf
        to_file_base: 
C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/CacheItem.PJ3672
        from_format:  pdf
        to_format:    png
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\graphics\GraphicsConverter.cpp(264):
 build_script ... 
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\graphics\GraphicsConverter.cpp(376):
 ready!
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\graphics\GraphicsConverter.cpp(142):
   Conversion script:
--------------------------------------
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, shutil, sys

def unlinkNoThrow(file):
  ''' remove a file, do not throw if an error occurs '''
  try:
    os.unlink(file)
  except:
    pass

infile = 
"E:/studium/diplomarbeit/labbook/3.Lyx/images/fe-100-s5-100gb-supercellsize-convergence.pdf"
outfile = 
"C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/gconvert6.ER3672.pdf"
shutil.copy(infile, outfile)
os.chdir("C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/")
infile = 
"C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/gconvert6.ER3672.pdf"
infile_base = 
"C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/gconvert6.ER3672"
outfile = 
"C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/gconvert6.ER3672.ps"
outdir  = os.path.dirname(outfile)

if os.system(r'pdf2ps ' + '"' + infile + '"' + ' ' + '"' + outfile + '"' + '') 
!= 0:
  unlinkNoThrow(outfile)
  sys.exit(1)

if not os.path.isfile(outfile):
  if os.path.isfile(outfile + '.0'):
    os.rename(outfile + '.0', outfile)
    import glob
    for file in glob.glob(outfile + '.?'):
      unlinkNoThrow(file)
  else:
    sys.exit(1)

unlinkNoThrow(infile)

infile = 
"C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/gconvert6.ER3672.ps"
infile_base = 
"C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/gconvert6.ER3672"
outfile = 
"C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/gconvert6.ER3672.eps"
outdir  = os.path.dirname(outfile)

if os.system(r'ps2eps ' + '"' + infile + '"' + '') != 0:
  unlinkNoThrow(outfile)
  sys.exit(1)

if not os.path.isfile(outfile):
  if os.path.isfile(outfile + '.0'):
    os.rename(outfile + '.0', outfile)
    import glob
    for file in glob.glob(outfile + '.?'):
      unlinkNoThrow(file)
  else:
    sys.exit(1)

unlinkNoThrow(infile)

infile = 
"C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/gconvert6.ER3672.eps"
infile_base = 
"C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/gconvert6.ER3672"
outfile = 
"C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/gconvert6.ER3672.png"
outdir  = os.path.dirname(outfile)

if os.system(r'convert ' + '"' + infile + '"' + ' ' + '"' + outfile + '"' + '') 
!= 0:
  unlinkNoThrow(outfile)
  sys.exit(1)

if not os.path.isfile(outfile):
  if os.path.isfile(outfile + '.0'):
    os.rename(outfile + '.0', outfile)
    import glob
    for file in glob.glob(outfile + '.?'):
      unlinkNoThrow(file)
  else:
    sys.exit(1)

unlinkNoThrow(infile)

fromfile = outfile
tofile = 
"C:/Users/klaus/AppData/Local/Temp/lyx_tmpdir.Hp3672/CacheItem.PJ3672.png"

try:
  os.rename(fromfile, tofile)
except:
  try:
    shutil.copy(fromfile, tofile)
  except:
    sys.exit(1)
  unlinkNoThrow(fromfile)

--------------------------------------

C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\support\ForkedCalls.cpp(495):
 ForkedCallQueue: waking up
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\support\ForkedCalls.cpp(504):
 ForkedCallQueue: I'm going to sleep
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\graphics\GraphicsCacheItem.cpp(263):
 Image conversion failed.
C:\Users\Vincent\Documents\LyX\source\lyx-svn-branch\src\graphics\GraphicsCacheItem.cpp(273):
 Unable to find converted file!

Reply via email to