vcsred
vcsred

Reputation: 29

java.lang.IllegalArgumentException: image == null

we are getting the exception while reading the image,but i have an image in location path.Please suggest us?

byte photoContentByte[] = null;
BufferedImage originalImage = ImageIO.read(new File("D:/xyz/Repository/1234567890.tif"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(originalImage, "jpeg", baos);
baos.flush();
photoContentByte = baos.toByteArray();
baos.close();

Upvotes: 0

Views: 3865

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172458

Try this:

BufferedImage originalImage = ImageIO.read(new FileInputStream("D:/xyz/Repository/1234567890.tif"));

EDIT:

As resolved in comments, you have a typo in file extension. It should be

BufferedImage originalImage = ImageIO.read(new File("D:/xyz/Repository/1234567890.tiff"));

i.e., the file extension needs to be tiff and not tif

Upvotes: 1

Related Questions