Is there a Python library for creating thumbnails for various document file formats?

I would like to create sketches from various file formats such as odt, doc (x) and ppt (x), as well as mp4, psd, tiff (and possibly others) from a Python application. As far as I know, for each of these formats there is at least one open source application that can generate preview images / thumbnails (e.g. LibreOffice, ffmpeg) or at least extract embedded thumbnails (e.g. imagemagick).

My main problem is that each of these applications / libraries uses different command-line options, so I'm looking for a Python library (or a unified CLI tool) that provides a high-level API for creating a sketch with the specified parameters, the quality level specified with file name, and invokes the appropriate external tool (ideally, including bycatch exceptions, segfaults, and timeouts). Bonus points if it can generate several thumbnails on demand (for example, one per page, page XY, every Z seconds, but no more than N images).

Does anyone know such a library / utility? (Boundary condition: files can contain sensitive material or can be quite large, so this should work without any network connection, using an external web service is impossible).

If Python doesn't have this kind of thing, a locally installed web service will also be great.

+4
source share
2 answers

In the end, I wrote my own library (called anythumbnailer , a MIT license) that worked well enough for my immediate needs. The library is not what I intended (only basic thumbnailing, no measurement support, ...), but it can generate thumbnails for doc (x), xls (x), ppt (x), video and pdf on Linux using ffmpeg, LibreOffice and ffmpeg.

+5
source

. preview-generator - - , pdf, json- . jpeg, pdf, text, htlm json . , .

+1

Source: https://habr.com/ru/post/1524936/


All Articles