for(File f: files)
{
IBitmap origbitmap = new BitmapBufferedImageImpl(ImageIO.read(f));
Assert.assertTrue(origbitmap.getHeight() > 0 && origbitmap.getWidth() > 0);
System.out.println(origbitmap.getHeight() + " : " + origbitmap.getWidth());
IOpenJPEG iojpeg = new OpenJPEGFactoryImpl().getIntance();
byte[] bytearray = iojpeg.EncodeFromImage(origbitmap, false);
Assert.assertTrue(bytearray.length > 0);
System.out.println("Output File: " + fileLocation.getPath() + "/" + f.getName() + ".jp2");
FileOutputStream fos = new FileOutputStream(new File(fileLocation.getPath() + "/" + f.getName() + ".jp2"));
fos.write(bytearray);
fos.flush();