light-weight C++ image library

YePhIcK picture YePhIcK · Aug 5, 2012 · Viewed 34.3k times · Source

I've been looking around for a simple and small yet robust and fast (not comprehensive!) image library for C++ (C would suffice, if no C++ version is available).

Main features I'm looking for are:

  • Free (opensource is a plus)
  • Built for speed
  • No huge functional bloat (like ImageMagik, which is truly comprehensive but is a mammoth)
  • Tiny memory footprint
  • Only supports the absolute minimum of functions like load/save, resize, convert between formats. Nothing fancy
  • Error recovery for "broken" files (unlike stb_image.c, which has pretty poor error recovery)
  • MSVC and gcc friendly (I used CxImage for a number of years but with the latest version I'm having problems with MSVC 2010 and it would seem that active development and support for it has died out by now, so I'm about to drop it)
  • Should support popular modern formats, like JPEG2000, either directly or via a use of general libraries like libpng
  • Don't care if it's DirectX or OpenGL as I don't plan on using it to display the images - only to file-process them for a web site
  • Having support for both static and dynamic linking is a plus
  • Threading support is a huge plus

Libraries I looked at and dismissed for one reason or another:

  • CxImage (no active development on it anymore)
  • ImageMagik - too huge (and slow)
  • stb_image.c - bad error handling, doesn't support enough image formats
  • DevIL (havn't dismissed yet, but haven't looked at it much either - just learnt of it a few minutes ago on a similar post on SO) - based on it's size and feature set it looks very promising for what I need though
  • FreeImage (same as DevIL - will take a look at it shortly but it's a bit big in size to my taste)
  • SOIL (same as stb_image.c)
  • TimThumb - it's a PHP, not a C/C++

In short I just want something as tiny as possible and as fast as possible at the expense of just having the absolute bare minimum of functionality but I'm yet to find a suitable candidate thus far.

Any suggestions from this community, please? But keep in mind the constraints I listed above - I don't think it's OK to throw an answer of a form "have you tried X?" where "X" doesn't meet half of my needs :)

Edit: Looking a bit more into DevIL it would seem it could be what I need. It's light, tiny, robust. Now I just need to make sure it performs. Oh, and CImage (I forgot to mention it in the list) - didn't like it's performance (though I have to admit that the idea of template-only implementation is cute, to say the least)

Answer

Gigi picture Gigi · Aug 5, 2012

I strongly suggest you to write a little library around libpng and jpeglib (and every other low-level library for the formats you need to support). It is not that hard and you can code all the features you require.

As an alternative, you can use some of the good c++ wrappers that already exists for that libraries. Here are some examples: