for (int i = 0; i < fileName.length; i++)
{
pis = new FileInputStream("data/test/JPEGImageUtilTestCase/truth/" + fileName[i] + ".ppm");
image = decoder.decodeImage(pis);
jos = new FileOutputStream("/tmp/" + fileName[i] + ".jpg");
encoder.encodeImage(image, null, jos);
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("compare -metric PSNR data/test/JPEGImageUtilTestCase/truth/" + fileName[i] + ".ppm /tmp/" + fileName[i] + ".jpg /tmp/psnr.png");
Scanner scanner = new Scanner(new InputStreamReader(pr.getErrorStream()));
float psnr = scanner.hasNextFloat() ? scanner.nextFloat() : 0;
assertTrue(fileName[i] + " PSNR is too low : " + psnr, psnr > 30);