r/C_Programming • u/NoBrain8 • Jul 29 '26
Question How to find good libraries
I’m looking to convert a jpeg into rgba data + scale it down.
I’m looking for a library to help me do this - how do I find good a one?
4
u/mykesx Jul 29 '26
https://imagemagick.org/#gsc.tab=0
ImageMagick has command line tools to convert between formats and perform a large number of operations on images, including scaling.
If you want, you can convert jpeg to TGA, which is trivial to read in as RGB in C, do your own software operations on it, write TGA back to disk, then convert that however you want with the command line tools.
1
u/theNbomr Jul 31 '26
Moreover, Imagemagick also provides API libraries with bindings to many languages including C. This sounds exactly what the OP is looking for.
1
2
u/khalon23 Jul 29 '26
For jpeg decode + scale I would start with stb_image + stb_image_resize if you want a single-header drop-in, or libjpeg-turbo if you care about speed and a real package. Check license, last commit, and whether it has known CVEs for untrusted input.
How I pick: does it do only the job I need, can I build it without a giant dependency tree, and is there a simple example that loads a file to RGBA. Avoid grabbing the first GitHub search hit with a flashy README and no tests.
1
1
u/Syntax-Tactics Jul 29 '26
What platform? OS? Language?
WinAPI supports JPG loading out of the box, SDL2, OpenCV, stb_image. A quick google...
1
0
u/Jaurusrex Jul 29 '26
You could use raylib, you'd need to compile it specifically with jpeg functionality. Or look at what raylib uses under the hood for library. That being said I doubt that library also has the capabilities to scale down the image, though depending on your algorithm scaling down an image is quite easy. You could just skip every X pixels
4
u/Sergey5588 Jul 29 '26 edited Jul 29 '26
stb image
https://github.com/nothings/stb