I am using the following code to convert an image to a PNG file:
I would like to know how can I reduce the file size of the converted file. I read there is a trick which can reduce the color map of the result image without losing much image quality.
There's example code that shows how to compress an image to a JPEG here. It's possible that it works out of the box with PNGs as well (I'm not sure about the algorithms PNG uses), or -worst case- you can write a JPEG in the desired quality/compression, read it back into memory, and then write it as a PNG.