Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > ImageIO and Tiff images

Reply
Thread Tools

ImageIO and Tiff images

 
 
mark jason
Guest
Posts: n/a
 
      12-15-2010
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

 
Reply With Quote
 
 
 
 
Knute Johnson
Guest
Posts: n/a
 
      12-15-2010
On 12/15/2010 07:30 AM, mark jason wrote:
> 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.

--

Knute Johnson
s/nospam/knute2010/
 
Reply With Quote
 
 
 
 
John B. Matthews
Guest
Posts: n/a
 
      12-15-2010
In article
<(E-Mail Removed)>,
mark jason <(E-Mail Removed)> wrote:

> 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):

<http://java.sun.com/javase/technologies/desktop/media/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>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
 
Reply With Quote
 
Tom Anderson
Guest
Posts: n/a
 
      12-15-2010
On Wed, 15 Dec 2010, Knute Johnson wrote:

> On 12/15/2010 07:30 AM, mark jason wrote:
>
>> 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

>
> 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

--
Three o'clock is always too late or too early for anything you want to do.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      12-16-2010
On Wed, 15 Dec 2010 07:30:04 -0800 (PST), mark jason
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone who
said :

>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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ImageIO Tools] Writing float data as TIFF Andreas Jaeger Java 0 01-14-2005 04:14 PM
Tool for converting 12-bit TIFF images to 16-bit TIFF-images? Peter Frank Digital Photography 11 12-13-2004 02:41 AM
reading large jpeg / jpg files error on java imageio read: javax.imageio.IIOException: Unsupported Image Type Davidski Java 0 11-05-2004 09:44 PM
Image::Info::TIFF - multi-page tiff images page count ifiaz Perl Misc 1 11-19-2003 05:25 AM
javax.imageio.ImageIO.write() failed to find a png writer F C Java 2 10-01-2003 11:47 AM



Advertisments