In case anyone's planning to thumbnail some PNGs and JPEGs in Python, whether you use PyQt, PyOpenCV, or write your own little wrapper around Rust's `image` crate using PyO3 or rust-cpython, I recommend not using Pillow.

On my test corpus with a warmed cache, the others consistently took about 2/3rds the time Pillow did... though PyOpenCV was a hair slower than the others at ~25 seconds rather than ~23. (Pillow was ~33.)

@ssokolow Huh and I always though that it's particularly easy to use some shell script and ImageMagick...

@phel It's for populating the XDG shared thumbnail cache for a PyQt-based GUI I'm writing. The only reason I explored alternatives to doing it in PyQt is that I have prior experience flipping grids of pixels back and forth between PyQt and PyOpenCV and wanted to optimize for performance.

@ssokolow In this case, one way to go about it is to use the systems provided thumbnailer via dbus... should not be much more than a few calls...

Follow

@phel Three problems with that. First, Kubuntu Linux 20.04 LTS doesn't provide an org.freedesktop.thumbnails.Thumbnailer1 implementation. Second, I like to keep my options open for py2exe-ing Windows builds... which means no dependencies on external system services. Third, that'd just slow things down even if I *weren't* planning to calculate some hashes while I have the image loaded into memory anyway.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.