Avatar of jjacksn
jjacksn asked on

How to read Tiff file in Java (Is JAI the correct way?)

I'm trying to get a Tiff file into a buffered image to feed to an API that looks for barcodes.  I have looked around the web and found a couple of ways to do it, one of them is here:


Is JAI what I should be using here?

I also have this sample code:

PlanarImage im = null;
im = JAI.create("fileload", file.getAbsolutePath());

and also not sure if that is the way to go.  The person's project I am trying to edit only including JAI_codec.jar, so I do not believe I have access to the JAI object.

Avatar of undefined
Last Comment

8/22/2022 - Mon

Try something like
BufferedImage bi = ImageIO.read(new File("x.tiff"));

Open in new window


That returns a null object in my unit test.  could it be that I have a badly formatted tiff file?  tiff file loads fine in windows.

jai_codec.jar is included in my build path as well
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thanks it works well client.  Trying to to do this in a servlet now and its not working although the unit tests are working client side.  I'm guessing that I'm not exporting the jar into the WAR file, although i have it checked in the J2EE module dependencies in eclipse.  Is there a programmatic check i can do in the servlet to make sure it has access to jai_imageio.jar?

add a new question here:



We'll sort it out