I'm using ImageMagick for this kind of task, usually approaching it via compression/quality or resolution. Example:
mogrify -resize 800x600 -quality 70
But according to the list of command line options, an approach better matching your requirements is using the
jpeg:extent=value parameter (e.g.
-define jpeg:extent=2048KB). This will work via compression/quality alone, not reducing the resolution (if I understood the documentation correctly; I've never played with this option. You are free to combine it with
Restrict the maximum JPEG file size, for example
-define jpeg:extent=400KB. The JPEG encoder will search for the highest compression quality level that results in an output file that does not exceed the value. The
-quality option is ignored if it is also present.
ImageMagick is cross-platform, and provides Binary Releases for Linux, Mac OS X, iOS, and Windows alike. It supports a ton of graphic formats (including your requested
.png). So this should fit your requirements. Due to its working from the command line, it's also faster than many other approaches (as it doesn't have to load a GUI first).
This is a pretty mighty package for image manipulation, so you can use it for many other related tasks as well: montage, animate, compare, identify (i.e. show image meta data), convert between different formats, … Might take a little time to grasp it all, though :)