I need to read a Text(Account Number) from a image file (.tif).
I tried the following approach :
try{
File newFile=new File("C:\\Image\\9R6-CCI\\09082010\\K08E091209FT_8021.tif");
BufferedImage buffImage=ImageIO.read(newFile);
ByteArrayOutputStream os= new ByteArrayOutputStream();
ImageIO.write(buffImage,IMAGE_TYPE,os);
byte []data=os.toByteArray();
String imageString=new BASE64Encoder().encode(data);
}catch (Exception e){}
But it was throwing problem. After googling, I found that
ImageIO has some limitation to read an editable image.
Then, I tried the following approach :
try{File newFile=new File("C:\\Image\\9R6-CCI\\09082010\\K08E091209FT_8033.tif");
byte[] fileData = new byte[ (int)newFile.length()];
InputStream inStream = new FileInputStream( newFile);
inStream.read(fileData);
inStream.close();
String tempFileData = new String(fileData);
String imageString=new BASE64Encoder().encode(fileData);
}catch (Exception e){}
But i did n't get the desired out put . The Out put is as below.
xTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMUx
Please, help me to address the issue.
Thanks and Regards
Gautam