CHM e-book cover extraction

Posted on

Problem :

I would like to extract a “book cover image” from a series of CHM files, which command line tool can do that, please?

I have looked at the source of the QuickLook plug-in “quickchm1.1_source” and at the calibre command line conversion options (ebook-convert) but couldn’t find anything akin to simple:

name_of_tool file_to_convert output_image

as in:

mytool routermanual.chm routermanualcoverimage.png

Solution :

CHM is basically just “compiled HTML”. I’m not sure if you could create an image from the first page, but have a look at Calibre which will allow you to convert the CHM to a PDF.

From the PDF you should be able to create an image from the first page via imagemagick:

 $ convert "something.pdf[0]" cover.jpg

The chmls command in the Free Pascal distribution has an extract command.

CHMs have no explicit cover though, but a default html page (which might embed the image). This means you might have some parsing to do to extract the name of that image from the html.

Currently the chmls command doesn’t have a command to print the name of that html page. I’m preparing a new revision, and future versions will.

Leave a Reply

Your email address will not be published. Required fields are marked *