Pandoc: EPS mistaken for TGA image

Created on 10 Apr 2015  Â·  13Comments  Â·  Source: jgm/pandoc

For some reason Pandoc detects the linked eps file as tga file
and complains about invallid tga data, thus failing to compile the
document.

Files: test.pan, eps-mistaken-for-tga.eps
Command: pandoc -o test.pdf test.pan

Expected result: pdf file with a image in it
Actual result: Pandoc fails with error message "pandoc: No data detected in TGA file"

All 13 comments

I may be wrong, but it looks like Pandoc will try to convert embedded images to png if they are not jpg, png or pdf. The error seems to be coming from the library (JuicyPixels) used for conversion - TGA was the last format it tried to interpret the file as. With some other eps files I got the following message:

Cannot load file
Jpeg Invalid marker used
PNG Invalid PNG file, signature broken
Bitmap Invalid Bitmap magic identifier
GIF Invalid Gif signature : %!PS-A
HDR Invalid radiance file signature
Tiff Invalid endian tag value
TGA demandInput: not enough bytes

I'm not sure whether converting these eps files to png or even pdf (using f.ex. epstopdf) is a feasible alternative in your case.

LaTex & Pandoc experts may be able suggest more alternatives.

I have used a dozen of esp files and after failing the conversion pandoc just simply
passes them on directly with the 'Cannot load file....' message, but everything works
and I have beautiful graphics that scale well and my documents stay ridiculously small
in file size, despite being heavy on the graphics.

I had to include this particular file in my document with direct LaTeX commands.
Not a big deal, but this bug is really most intriguing, what exactly makes the image
library think this is a TGA image.

Is the error exactly as nkalvi suggests?

On Fri, Apr 10, 2015 at 11:35 PM, Jesse Jaara [email protected]
wrote:

I have used a dozen of esp files and after failing the conversion pandoc
just simply
passes them on directly with the 'Cannot load file....' message, but
everything works
and I have beautiful graphics that scale well and my documents stay
ridiculously small
in file size, despite being heavy on the graphics.

I had to include this particular file in my document with direct LaTeX
commands.
Not a big deal, but this bug is really most intriguing, what exactly makes
the image
library think this is a TGA image.

—
Reply to this email directly or view it on GitHub
https://github.com/jgm/pandoc/issues/2067#issuecomment-91709485.

https://github.com/Twinside/Juicy.Pixels/blob/master/src/Codec/Picture.hs

-- | If you want to decode an image in a bytestring without even thinking
-- in term of format or whatever, this is the function to use. It will try
-- to decode in each known format and if one decoding succeeds, it will return
-- the decoded image in it's own colorspace.
decodeImage :: B.ByteString -> Either String DynamicImage
decodeImage str = eitherLoad str [("Jpeg", decodeJpeg)
                                 ,("PNG", decodePng)
                                 ,("Bitmap", decodeBitmap)
                                 ,("GIF", decodeGif)
                                 ,("HDR", decodeHDR)
                                 ,("Tiff", decodeTiff)
                                 ,("TGA", decodeTga)
                                 ]

https://github.com/Twinside/Juicy.Pixels/blob/master/src/Codec/Picture/Tga.hs

  case imageType of
    ImageTypeNoData _ -> fail "No data detected in TGA file"

if you have time :smile:

@mpickering:
With this particular file the error is "pandoc: No data detected in TGA file".
But with all other of my esps pandoc warns about not being able to
load the file, with an error message like in @nkalvi's first post.

@nkalvi has the correct diagnosis of what is happening and why.
I think the best solution is to change the error message so it's less misleading. I'm working on that now.

Pandoc v2.1.3 still produces the warnings when .eps graphics is used. The .pdf generated works fine though.

[WARNING] Could not convert image '.\tex2pdf.8984/1584dee44acc53dcdff0a35199b4ba7a7aae4c17.ps': Cannot load file
  Jpeg Invalid marker used
  PNG Invalid PNG file, signature broken
  Bitmap Invalid Bitmap magic identifier
  GIF Invalid Gif signature : %!PS-A
  HDR Invalid radiance file signature
  Tiff Invalid endian tag value
  TGA not enough bytes

Hm, EPS should work. Can you upload the image file
so we can test?

jiucenglou notifications@github.com writes:

Pandoc v2.1.3 still produces the warnings when .eps graphics is used. The .pdf generated works fine though.

[WARNING] Could not convert image '.\tex2pdf.8984/1584dee44acc53dcdff0a35199b4ba7a7aae4c17.ps': Cannot load file
  Jpeg Invalid marker used
  PNG Invalid PNG file, signature broken
  Bitmap Invalid Bitmap magic identifier
  GIF Invalid Gif signature : %!PS-A
  HDR Invalid radiance file signature
  Tiff Invalid endian tag value
  TGA not enough bytes

--
You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub:
https://github.com/jgm/pandoc/issues/2067#issuecomment-383261301

@jlmuir .ps is PostScript, convert it to .eps (encapsulated postscript) first.

Sample files are zipped and attached as mega link https://mega.nz/#!UlQ1QSpa!4kgE2l5dLUSsXjhJnPmzud8nHx0PHjz3qviQHB5Edsg because I could not upload it with GitHub... Could you help to check ? Many thanks !

The command to run is "mp MWE.md" with the following shell function definition.

mp ()
{
    mdname=$1;
    mdname=$(basename "$mdname");
    name_noext="${mdname%.*}";
    docx_name="${name_noext}.docx";
    tex_name="${name_noext}.tex";
    pdf_name="${name_noext}.pdf";
    pandoc ${mdname} --mathml --filter=pandoc-crossref --filter=pandoc-citeproc -s -o ${docx_name};
    pandoc ${mdname} --mathml --filter=pandoc-crossref --filter=pandoc-citeproc -s -o ${tex_name} --pdf-engine=xelatex;
    pandoc ${mdname} --mathml --filter=pandoc-crossref --filter=pandoc-citeproc -s -o ${pdf_name} --pdf-engine=xelatex
}

I see what is happening here. Pandoc is assigning the
mime type application/postscript, and then assigning
the ps extension based on that mime type.

We can fix this by using the alias application/eps for
eps files.

OK, I've fixed the issue.

Thanks for your efforts ! I will test when the new version containing the fix is released.

Was this page helpful?
0 / 5 - 0 ratings