I'm trying to convert (several) PNG files to an indexed black and white (1-bit) palette image in linux via a bash script (or C code). If I use Gimp and take menu options Image, Mode, Indexed I get the "Indexed Colour conversion" dialog and can select "Use black and white (1-bit) palette" and "Remove unused and duplicate colors from colormap" options. If I then export the file I get a desired (black and white) indexed file. I want to do this via bash or part of code (preferably c).
I've tried using a imagemagick convert with threshold of 50% this looks approx like what I want bit the output is greyscale not indexed.