Fernando,

Fernando Roig wrote:

LyX displays the ppm file but not properly. I mean, it appears an image on the screen, but this image has less to do with the original ps figure. Therefore, ImageMagick is converting the ps file into a ppm file containing some strange information that LyX is able to display but GIMP is not able to open ("plugin cannot open image")

This may have to do with a character encoding issue; see below.


If I run

convert figure1.ps figure1.jpg

and then

convert figure1.jpg figure1.ppm

then both jpg and ppm files are correctly converted (I am able to open them in GIMP) and LyX displays the ppm file without problems. However, if I try to load the jpg file in LyX then I get the "Error converting to loadable format". So I believe that the problem is not with Ghostscript.

I'm not sure if this is consistent with an encoding problem, but possibly.


Here is the debug log (it is quite a lot of stuff):

[...]

[graphics::CacheItem::Impl::convertToDisplayFormat]
        Attempting to convert image file: C:/TEST/figure1.ps
        with displayed filename: C:\TEST\figure1.ps
Recognised Fileformat: eps

        The file contains eps format data.

I think this is ok, particularly if your figure1.ps is actually an EPS file.

The image loader can load the following directly:
bmp, pbm, pgm, png, ppm, xbm, xpm,
Of these, LyX recognises the following formats:
bmp, pbm, pgm, png, ppm, xbm, xpm

Unable to convert from eps to bmp
Unable to convert from eps to pbm
Unable to convert from eps to pgm
        Converting it to png format.

The next error (which occurs twice) suggests the encoding problem.

Error returned from iconv
EILSEQ An invalid multibyte sequence has been encountered in the input.
When converting from UTF-8 to UCS-4LE.

If I understand this correctly (character encodings are not my forte), the script is trying to convert the EPS file from UTF-8 to UCS-4LE (a new one to me) and is choking on something.

[...]

        Conversion script:
--------------------------------------
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, shutil, sys, locale

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

def utf8ToDefaultEncoding(file):
  ''' if possible, convert to the default encoding '''
  try:
    language, output_encoding = locale.getdefaultlocale()
    if output_encoding == None:
      output_encoding = 'latin1'
    return unicode(file, 'utf8').encode(output_encoding)
  except:
    return file



I didn't see where the utf8ToDefaultEncoding function was called in the conversion script, but maybe I'm just being stupid today. Do you know what character encoding was used to create figure1.ps? Also, what locale is set for you machine? I'm not sure what Python's getdefaultlocale() function looks at; it might be the LANG environment variable, but that's just a guess.

We may need a developer to help out with this (someone familiar with the operation of the graphics conversion script).

/Paul

Reply via email to