light-weight C++ image library

38,970

Solution 1

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:

Solution 2

Look at CImg library, it's just one single header file

Share:
38,970
YePhIcK
Author by

YePhIcK

Updated on November 03, 2020

Comments

  • YePhIcK
    YePhIcK over 3 years

    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)

  • YePhIcK
    YePhIcK almost 12 years
    I was not satisfied with the memory footprint and its performance
  • YePhIcK
    YePhIcK almost 12 years
    Looks like that's the route I'm going to take, after all :)
  • Octopus
    Octopus over 10 years
    It is simple and light but I'm pretty sure this library causes occasional memory segmentation faults.
  • NPS
    NPS over 10 years
    Pretty sure? Can anyone confirm or deny this? I'm considering using it in my project.
  • Water
    Water about 6 years
    @Octopus Checking for a response since the guy who was responding to you didn't highlight you properly. I understand it's been 5 years and you may not have the answer, but what you said is a very serious claim against the library since people -- like me -- hesitate very strongly against using a library that "segfaults".
  • Ray
    Ray almost 4 years
    I've used it for a while and I'm surprised at how extremely slow its IO seems to be, for PNG files anyway. I haven't looked too much into the details, but saving a single 1080 by 1920 PNG file takes about 5 seconds for some reason. Oh by the way, I have an absolute monster of a machine (Windows 10).