capture process output in Groovy
You can also do
Process pngquantCmd = imgCommand.execute();
def output= pngquantCmd.text;
println("Output : " + output);
Instead of
pngquantCmd.consumeProcessOutput(System.out, System.err)
Which will start a couple of threads to read the outputs and plough on regardless of the process' situation, you should try
pngquantCmd.waitForProcessOutput(System.out, System.err)
Which will redirect the process output and then wait for it to finish before moving on :-)