Dealing with 16-bit PNG file

Jimmy Ye
Feb 4, 2022

I recently have to generate 16-bit RGB PNG files, so I spent some time investigating what libraries I could use.

stbi_image (C/C++)

only supports 8 bit depths.
Tutorial at: https://solarianprogrammer.com/2019/06/10/c-programming-reading-writing-images-stb_image-libraries/

libpng (C/C++)

It supports 16-bit RGB PNG.
Tutorial at: https://www.youtube.com/watch?v=GsgSnSG0O0U
libpng example code: https://www.lemoda.net/c/write-png/

PIL/Pillow (Python)

It supports 16-bit grayscale PNG writing and 8-bit RGB PNG writing.

Matplotlib (python)

It supports 8-bit RGB/Gray PNG writing.

OpenCV (python and C/C++)

It supports both 8-bit and 16-bit RGB/Gray PNG writing.

--

--