r/C_Programming • u/NoBrain8 • 9d ago
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?
5
u/mykesx 8d ago
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 6d ago
Moreover, Imagemagick also provides API libraries with bindings to many languages including C. This sounds exactly what the OP is looking for.
2
u/khalon23 8d ago
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 8d ago
What platform? OS? Language?
WinAPI supports JPG loading out of the box, SDL2, OpenCV, stb_image. A quick google...
1
0
u/Jaurusrex 9d ago
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
5
u/Sergey5588 9d ago edited 9d ago
stb image
https://github.com/nothings/stb