Getting thumbnails of arbitrary file types

I need to get thumbnails from arbitrary file types. (Or as much as possible.)

For images similar to file types, I can use image magic. For documents like files, I think I will use:

Document → (Open office with Pyuno) PDF → (Image-magick) Pdf for images. → Thumbnail of the first page.

  • Is there a better way to do this?
  • Is there a web service that can do this?
+4
source share
1 answer

Yes, I think you got it right. Of course, there are some web services, although I have no experience using them, so I will not list them here.

Creating a document thumbnail requires rendering documents and office documents such as docx to be so complex that only very few libraries / applications can display them. LibreOffice seems to be the best choice in this area.

Fortunately, a Python script already exists that provides a command line interface for conversion using LibreOffice / OpenOffice: unoconv . It should be able to use all export filters present in the office suite (including png and pdf).

I noticed that some problems are exported directly to png, but pdf export was mostly fine.

Btw: If you have problems with imagemagick, you can try ghostscript.

+1
source

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


All Articles