How do I read JPEG and PNG pixels in C++ on Linux?

Nick Bolton picture Nick Bolton · Mar 29, 2009 · Viewed 65.9k times · Source

I'm doing some image processing, and I'd like to individually read each pixel value in a JPEG and PNG images.

In my deployment scenario, it would be awkward for me to use a 3rd party library (as I have restricted access on the target computer), but I'm assuming that there's no standard C or C++ library for reading JPEG/PNG...

So, if you know of a way of not using a library then great, if not then answers are still welcome!

Answer

Nils Pipenbrinck picture Nils Pipenbrinck · Mar 29, 2009

There is no standard library in the C-standard to read the file-formats.

However, most programs, especially on the linux platform use the same library to decode the image-formats:

For jpeg it's libjpeg, for png it's libpng.

The chances that the libs are already installed is very high.

http://www.libpng.org

http://www.ijg.org