jgm / pandoc

Universal markup converter
https://pandoc.org
Other
33.84k stars 3.33k forks source link

pandoc metadata "cover-image" doesn't recognize WebP image #9561

Open selden opened 5 months ago

selden commented 5 months ago

Explain the problem. Problem: pandoc metadata "cover-image" doesn't recognize WebP image. It should.

The command line

    pandoc test_webp.html -o test_webp.epub \
       --metadata cover-image="front_cover.webp"

generates the warning message

    [WARNING] Could not determine image size for front_cover.webp: could not determine image type

It'd be nice if the problem causing this warning could be fixed.

Pandoc version? This warning is seen when using pandoc 3.1.12.2 under Windows 10 Pro x64 22H2 build 19045.4046 with Cygwin 3.5.1

The .webp image file was created using ImageMagick 7.0.10-61 with the command

convert front_cover.jpg -resize 300x300 front_cover.webp

so I think the format of the WebP file itself is OK.

The resulting .epub document does show the cover page image when displayed using the epub reader provided with Calibre 7.6. which again suggests that the file format is OK.

The attached zip file contains the following files which can be used to reproduce the warning message.

test_webp.sh test_webp.html front_cover.webp

test_webp.epub readme.txt

test_webp.zip

jgm commented 5 months ago

We'd need a way to get the size information from the WebP file. There's this: https://hackage.haskell.org/package/webp but the dependency on an external C library rules it out.

If there's an easy way to extract the size information we can just write some custom code for that, but the format seems rather complex.

Have you tried specifying explicit size information for your image? (Width and height attributes). That might avoid the warning.

selden commented 5 months ago

Edited yet again:

Sorry, I misread the docs. Indeed --epub-cover-image gives the same error message as --metadata cover-image even though the cover image is actually incorporated in the epub document.

(I'm still trying to find how to specify the image size in the pandoc command line.)

I've deleted the text of my misleading response.