Sunday, 23 February 2014

private InputStream convertToPNG(String path) throws IOException {
BufferedImage bufferedImg = ImageIO.read(new File(path));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bufferedImg, "png", baos);
baos.flush();
byte[] imageInByte = baos.toByteArray();
baos.close();

InputStream is = new ByteArrayInputStream(imageInByte);
return is;
}