ImageIO and Tiff images

Discussion in 'Java' started by mark jason, Dec 15, 2010.

  1. mark jason

    mark jason Guest

    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
    mark jason, Dec 15, 2010
    #1
    1. Advertising

  2. 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/
    Knute Johnson, Dec 15, 2010
    #2
    1. Advertising

  3. In article
    <>,
    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 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>
    John B. Matthews, Dec 15, 2010
    #3
  4. mark jason

    Tom Anderson Guest

    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.
    Tom Anderson, Dec 15, 2010
    #4
  5. mark jason

    Roedy Green Guest

    On Wed, 15 Dec 2010 07:30:04 -0800 (PST), mark jason
    <> 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.
    Roedy Green, Dec 16, 2010
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. F C
    Replies:
    2
    Views:
    5,150
  2. Max
    Replies:
    1
    Views:
    396
    David Zimmerman
    Mar 7, 2004
  3. Davidski
    Replies:
    0
    Views:
    3,880
    Davidski
    Nov 5, 2004
  4. Andreas Jaeger
    Replies:
    0
    Views:
    1,110
    Andreas Jaeger
    Jan 14, 2005
  5. ifiaz
    Replies:
    1
    Views:
    926
    Martien Verbruggen
    Nov 19, 2003
Loading...

Share This Page