any2jpg
Description
any2jpg is a Windows command-line utility that turns the first page of a document into a JPEG thumbnail. Input is either the document file itself or an archive (ZIP/TAR) containing a document; the format is detected automatically, page 1 is rendered at 400 px wide by default (tunable via -w, JPEG quality 85), and the result is saved to file.jpg.
The project builds a single self-contained executable (any2jpg.exe) with statically linked dependencies - no DLLs, no runtime, no installation. The utility is designed as a lightweight cover generator: for any common document format (or an archive with unknown contents) it quickly produces a small JPEG preview of the first page. Typical scenarios: generating covers/thumbnails for document catalogs and libraries, previewing documents stored in archives, building graphical indexes of mixed document collections.
The program is a single C file (main.c) driving two rendering engines: MuPDF - for PDF, EPUB, MOBI, FB2, DOCX, XLSX, PPTX, HTML and TXT; DjVuLibre - for DjVu. Both engines render the page into an in-memory RGB buffer, which is then encoded to JPEG by MuPDF's built-in JPEG encoder.
Modules used
- MuPDF 1.28 (mupdf/) - base document rendering engine. Parses and renders PDF, EPUB, MOBI, FB2, DOCX, XLSX, PPTX, HTML and TXT, provides the archive (ZIP/TAR) reader used for input files and the JPEG encoder used for output. Builds via mingw32-make in the release-tofu configuration: html=yes (HTML/EPUB support, pulls in the Gumbo HTML5 parser), tofu=yes (built-in font set compiled into the library as binary blobs), mujs/xps/svg/extract/threading=no (unneeded features disabled), ICC color management and word hyphenation disabled, SSE intrinsics disabled for maximum portability. The build produces two static libraries: libmupdf.a (engine) and libmupdf-third.a (bundled third-party code: FreeType, HarfBuzz, zlib, OpenJPEG, jbig2dec, lcms2, Gumbo, libjpeg, brotli and others)
- DjVuLibre 3.5.29 (djvulibre/) - DjVu decoding library. Compiled into a static library from the libdjvu sources with the JPEG decoder enabled (NEED_JPEG_DECODER), since the background layer of DjVu pages is often stored as JPEG. The program uses its asynchronous C API (ddjvuapi): the document is fed to the decoder, a message loop processes decoder events, and the first page is rendered into an RGB24 buffer
- libjpeg 9a (libjpeg/) - Independent JPEG Group codec, built into a static library from the core subset of encoder/decoder sources. Supplies the JPEG symbols DjVuLibre needs at compile time (in the final executable they resolve from the copy built into libmupdf-third.a)
- libwebp (libwebp/) - prebuilt static libraries libwebp.a and libsharpyuv.a (Google's WebP codec). Provide WebP image decoding inside MuPDF so documents with embedded WebP images render correctly
- zlib 1.2.8 (zlib/) - standard compression library used by DjVuLibre for zlib-compressed DjVu streams (MuPDF uses its own built-in copy of zlib)
Technologies
- Languages: C (main program), C++ (DjVuLibre)
- Toolchain: MinGW-w64 (gcc/g++ 15.2, GNU ar, mingw32-make 4.4)
- Build system: a single batch file (build_any2jpg.bat) driving MuPDF's own Makefile plus direct compilation of the other libraries
- bash (from Git for Windows) is used by MuPDF's Makefile for resource-generation recipes
- PowerShell is used by the builder only for fast file-date comparison (incremental build checks)
- Platform: Windows x64