2

I wrote an app for Windows and macOS and I am in the process of porting it to Linux. My app has a file browser implemented and can display thumbnails or document icons of files.

On Windows I get access to the file thumbnails (or document icons if there is no thumbnail support) through the shell extensions.

On MacOS I can generate the thumbnails (or document icons) through QuickLook.

On Linux, what would be the way to go to...

1... generate a thumbnail e.g. for JPEGs, PNGs 2... fallback to extract document icons for the file if no thumbnail is available?

Thank you!

2
  • I know about this specific thumbnailer solution, called "tumbler"; it has been created for the XFCE desktop: docs.xfce.org/xfce/tumbler/start Maybe you could consider making it a dependency of your app, and let it do the thing for you? Or if you want to use some more direct approach, try to unearth one of the thumbnailer plugins tumbler uses under the hood: I guess the PixBuf thumbnailer plugin could be a versatile choice: docs.xfce.org/xfce/tumbler/available_plugins
    – Levente
    Commented Jun 12, 2021 at 14:43
  • Refer to any good GUI file manager such as nemo (for example). Commented Jun 12, 2021 at 22:51

2 Answers 2

3

You need a thumbnailer daemon like Tumbler.

It is a daemon, so running independently from your program and generates thumbnails for your files. Your program can connect to it whit DBus and then can send requests to the daemon to generate new thumnails. The already generated thumbnails can be found in a path specified by the "Thumbnail management DBus specification" standard. I don't know if QT based environments following the same standard or have their own mechanism.

For the "fallback" you should use the freedesktop standard for icon lookup, and the freedesktop mime database to mime guess the file. Depending on the language you use, usually you can find a library that implements these standards for you, and there is also a command line tool in xgd-utils as reference implementation of the standards. Sadly the way to store the name of the user preferred icon theme isn't standardised at all, and every DE has different solution.

And sorry for the necro, but this is the first result on related google searches.

0

1... generate a thumbnail e.g. for JPEGs, PNGs

GraphicsMagick/ImageMagick

I can't think of any APIs for Linux which can be used for that. GTK/Qt/FLTK/Enlightenment have widely different image libraries. In theory you could use libpng/libjpeg-turbo/libtiff and other similar libraries for other formats and then resize using your own algorithms.

2... fallback to extract document icons for the file if no thumbnail is available?

I don't understand this question, sorry.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .