Settings

Theme

Ask HN: Open framework for generating thumbnails on untrusted files?

2 points by dafelst 2 months ago · 4 comments · 1 min read

Reader

Hi HN - for part of a project I'm working on, I need to generate previews/thumbnails of files that may be untrusted. This would be across a variety of file types (the usual suspects like graphics files, documents, video), but also ideally is easily extended with downloadable "handlers" such that more obscure file types can be handled at run-time. Ideally the result is cross-platform in that it can be run on windows/linux/osx clients, but also on server infra (e.g. cloudflare workers).

I have searched the web and github (and had ChatGPT do that too) and while there are some frameworks out there like `preview-generator` in the python ecosystem and `thumbnailator`, they all seem to shell out to native handlers. While native handlers are all well and good and there are good examples for extensible plugin systems with native code, it does complicate things for runtime extensibility.

My initial thought was to define a simple function API and have the "handlers" implemented in WebAssembly such that they can be loaded and runtime and effectively sandboxed, one shot stream processors.

Does anyone know if anything project like this already exists, or does anyone have any advice?

coobird 2 months ago

Hi, author of Thumbnailator here.

Just FYI, Thumbnailator itself doesn't delegate processing to native processing -- it's just a wrapper around Java's Image I/O[1] functionality. In other words, it delegates the compression/decompression to loaded Image I/O plugins, hence, whether native processes are used depends on those plugins.

In terms of cross-platform support, the default Image I/O plugins that come with Java shouldn't be much of a concern. For 3rd party ones, IIRC there are some that will use native libraries, while others are pure Java. One good library on the Image I/O plugins front is TwelveMonkeys ImageIO[2], which provides plugins to support a wide variety of image formats.

1: https://docs.oracle.com/javase/8/docs/technotes/guides/image...

2: https://github.com/haraldk/TwelveMonkeys

fsflover 2 months ago

Perhaps you may be interested in Qubes OS, security-oriented OS, which allows to convert untrusted images to trusted ones using a disposable VM: https://github.com/QubesOS/qubes-app-linux-img-converter/blo...

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection