HACKER Q&A
📣 zahlman

Lightweight, low-level image loading usable from Python?


I'm looking for a bare-bones image loading and saving library for Python on Linux. Of course I'm aware of the standard options (PIL is possibly the smallest but it's still quite large), but I'm looking to prioritize something that is fast, simple and lightweight at the expense of anything else. I don't want to depend on NumPy and I don't want explicit functionality for manipulating the data in any way - I ideally just want a(n ideally mutable) byte buffer with the bitmap data and a `dict` with metadata such as the pixel format and dimensions (the bitmap itself could also be under a key, whatever).

The best candidate I could find on my own is https://pypi.org/project/smc.freeimage/ (by someone who's now a Python core developer), but it seems to have been abandoned 12 years ago at the 0.x stage (and while there's a source tarball, the BitBucket repo seems to have vanished).

Anyone know of alternatives? Is there a fork of PIL that cuts it down to just the Image module, for example?


  👤 compressedgas Accepted Answer ✓
I'd recommend you consider pygame.image which wraps SDL_image. I think it would be possible to strip pygame down to just the pygame.image module and pygame.Surface object as you want.