I stumbled on the same error with pandoc when trying to convert epub
to pdf :
[macfarlane@boulder]:(~/Documents)$ pandoc -s -t latex --toc --chapters \
--latex-engine=lualatex $BOOK.epub -o $BOOK.pdf
!LuaTeX error (file /tmp/tex2pdf.23440/3f21bef8dd2877aad72f5cddbf00284ca88fa0e7
.jpg): reading JPEG image failed (no marker found)
==> Fatal error occurred, no output PDF file produced!
pandoc: Error producing PDF
[macfarlane@boulder]:(~/Documents)$
Here's a workaround. Check to see if a tex file can be produced :
[macfarlane@boulder]:(~/Documents)$ pandoc \
-s -t latex \
--toc --chapters \
--latex-engine=lualatex $BOOK.epub -o $BOOK.tex
[macfarlane@boulder]:(~/Documents)$
Extract images and other media contained in the epub container to the
path DIR, creating it if necessary, and adjust the images references in
the [LaTeX] document so they point to the extracted files, with the
option --extract-media= DIR . Select the current directory which also
contains the ePub file. Add --extract-media=. which means extract in
the current directory, which is also $HOME/Documents
[macfarlane@boulder]:(~)$ cd Documents
[macfarlane@boulder]:(~/Documents)$ pandoc \
-s -t latex \
--toc --chapters \
--latex-engine=lualatex \
--extract-media=. $BOOK.epub -o $BOOK.tex
pandoc: extracting ./images/9781501144158.jpg
pandoc: extracting ./images/com-01.jpg
pandoc: extracting ./images/f0003-01.jpg
pandoc: extracting ./images/f0005-01.jpg
[ ----- extract-media logging shortened ---- ]
pandoc: extracting ./images/f0177-01.jpg
pandoc: extracting ./images/f0187-01.jpg
pandoc: extracting ./images/logo.jpg
pandoc: extracting ./images/logo1.jpg
pandoc: extracting ./images/title.jpg
[macfarlane@boulder]:(~/Documents)$
Repeal the extracted .jpg images by creating new LaTeX compatible JPEG
images with the `convert' utility (from the imagemagick program suite)
[macfarlane@boulder]:(~/Documents)$ cd images
[macfarlane@boulder]:(~/Documents/images)$ convert logo1.jpg logo1.jpeg
and Replace the previously with pandoc extracted .jpg images with the
newly created .jpeg images :
[macfarlane@boulder]:(~/Documents/images)$ mv logo1.jpeg logo1.jpg
One can do this with a single for loop on the commandline :
[macfarlane@boulder]:(~/Documents)$
[macfarlane@boulder]:(~/Documents)$ cd images/
[macfarlane@boulder]:(~/Documents/images)$ for i in *.jpg; do convert $i `echo $i | sed 's/jpg/jpeg/'`; done
[macfarlane@boulder]:(~/Documents/images)$ rm -f *.jpg
[macfarlane@boulder]:(~/Documents/images)$ for i in *.jpeg; do mv $i `echo $i | sed 's/jpeg/jpg/'`; done
[macfarlane@boulder]:(~/Documents/images)$ cd ..
[macfarlane@boulder]:(~/Documents)$
Run the first commandline again, but this time have the LuaTeX engine
seek for its \includegraphics in the same directory as where the ePub
images were extracted earlier
( --data-dir=DIRECTORY
Specify the user data directory to search for pandoc data files.
If this option is not specified, the default user data directory
will be used. This is, in Unix: $HOME/.pandoc )
by adding the option --data-dir=. :
[macfarlane@boulder]:(~/Documents)$ pandoc \
-s -t latex \
--toc --chapters \
--latex-engine=lualatex \
--data-dir=. $BOOK.epub -o $BOOK.pdf
[macfarlane@boulder]:(~/Documents)$
file(1)
command should tell you what the image file really contains (perhaps some tool-specific format, or some different format than you think?).