ImageIO and Tiff images

M

mark jason

hi
I was trying out some ImageIO methods on various types of image
files.When I tried getImageReaders() on ImageInputStream created with
jpeg,png files ,I could get at least one ImageReader.But it failed
when I used tiff images from http://www.fileformat.info/format/tiff/sample/index.htm
as well as those in JAFFE database.Can someone tell me why this
happens?

thanks
mark.

public static void checkImage(String name) throws IOException{
ImageInputStream imginstream = ImageIO.createImageInputStream(new
FileInputStream(name));
Iterator<ImageReader> iter = ImageIO.getImageReaders(imginstream);
if (iter.hasNext()) {
System.out.println("at least one image reader exists for " + name);
}else{
System.out.println("No image reader exists for " + name);
}
}

when I tried a .tiff file I got
No image reader exists for KLHA1158.tiff
 
K

Knute Johnson

hi
I was trying out some ImageIO methods on various types of image
files.When I tried getImageReaders() on ImageInputStream created with
jpeg,png files ,I could get at least one ImageReader.But it failed
when I used tiff images from http://www.fileformat.info/format/tiff/sample/index.htm
as well as those in JAFFE database.Can someone tell me why this
happens?

thanks
mark.

public static void checkImage(String name) throws IOException{
ImageInputStream imginstream = ImageIO.createImageInputStream(new
FileInputStream(name));
Iterator<ImageReader> iter = ImageIO.getImageReaders(imginstream);
if (iter.hasNext()) {
System.out.println("at least one image reader exists for " + name);
}else{
System.out.println("No image reader exists for " + name);
}
}

when I tried a .tiff file I got
No image reader exists for KLHA1158.tiff

You discovered the reason, there are no readers for tiff images. JAI
(Java Advanced Imaging) has readers to read tiffs. I haven't used it in
a while so I'm not sure but I think you need the JAI Image I/O tools
rather than the JAI.

Just do a google search for JAI and you will get more info than you
wanted. There are some pretty good forums too.
 
J

John B. Matthews

mark jason said:
I was trying out some ImageIO methods on various types of image
files. When I tried getImageReaders() on ImageInputStream created
with jpeg, png files, I could get at least one ImageReader. But it
failed when I used tiff images from

http://www.fileformat.info/format/tiff/sample/index.htm

as well as those in JAFFE database.

These tiff files can be opened using Java Advanced Imaging (JAI):

Can someone tell me why this happens?

The ImageReader class is abstract. Implementations rely on "the service
provider interface (SPI) class for the specific format."

<http://download.oracle.com/javase/6/docs/api/javax/imageio/ImageReader.html>

The method getReaderMIMETypes() will return a list of MIME types
recognized by your implementation. Similar methods exist for format
names and suffixes.

<http://download.oracle.com/javase/6/docs/api/javax/imageio/ImageIO.html>
 
T

Tom Anderson

You discovered the reason, there are no readers for tiff images. JAI
(Java Advanced Imaging) has readers to read tiffs. I haven't used it in
a while so I'm not sure but I think you need the JAI Image I/O tools
rather than the JAI.

Looks good:

https://jai-imageio.dev.java.net/binary-builds.html

They are, to reiterate Knute's point, readers for the ImageIO framework,
not for JAI. This is a good thing, because JAI is bonkers.

tom
 
R

Roedy Green

I was trying out some ImageIO methods on various types of image

import javax.imageio.ImageIO;

public class Jai
{
/**
* Display file formats supported by JAI on your platform.
* e.g BMP, bmp, GIF, gif, jpeg, JPEG, jpg, JPG, png, PNG, wbmp,
WBMP
* @param args not used
*/
public static void main ( String[] args )
{
String[] names = ImageIO.getWriterFormatNames();
for ( String name: names )
{
System.out.println( name );
}
}
}

Not tiff is not of of the out-the-box supported formats. You would
have to get it from a third party, or preconvert your images with
batch utitity.

--
Roedy Green Canadian Mind Products
http://mindprod.com

Doubling the size of a team will probably make it produce even more slowly.
The problem is the more team members, the more secrets, the less each team
member understands about how it all fits together and how his changes may
adversely affect others.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top