javax.imageio package dies reading PNG file

Discussion in 'Java' started by Robert Metzger, Jan 13, 2005.

  1. I am unable to get PNG reading to work using the javax.imageio.ImageIO package.
    I'm using PNG because ImageIO doesn't have a GIF writer
    (I need to both read and write) and the JPEG writer blurs
    my pictures in very ugly ways.

    Here's my code:

    File iconFile= null;
    BufferedImage image= null;
    try {
    iconFile= new File(PATH_TO_IMAGE);
    image= ImageIO.read(iconFile); // <<< ERROR OCCURS HERE
    } catch (IOException e ) {
    }

    Graphics2D gfx= image.createGraphics();
    gfx.setFont(new Font("Helvetica", Font.PLAIN, 10));
    gfx.setColor(new Color(255,255,255));

    int offset= // some integer
    gfx.drawString("Test",offset,48);

    try {
    ImageIO.write(image, "png", iconFile);
    } catch (IOException e ) {
    }

    Here's the error occuring in the ImageIO package

    Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: LUT has improper length!
    at javax.imageio.ImageTypeSpecifier$Indexed.<init>(Unknown Source)
    at javax.imageio.ImageTypeSpecifier.createIndexed(Unknown Source)
    at com.sun.imageio.plugins.png.PNGImageReader.getImageTypes(Unknown Source)
    at com.sun.imageio.plugins.png.PNGImageReader.readImage(Unknown Source)
    at com.sun.imageio.plugins.png.PNGImageReader.read(Unknown Source)
    at javax.imageio.ImageIO.read(Unknown Source)
    at javax.imageio.ImageIO.read(Unknown Source)

    The original PNG file was created by PaintShopPro.
    Mozilla Firefox and Internet Exploder have no problems displaying it.

    Any suggestions on how to read and write small graphic files (60x60 images)
    would be greatly appreciated.

    --
    Robert Metzger
    Hewlett-Packard Company
    High Performance Computing Division
     
    Robert Metzger, Jan 13, 2005
    #1
    1. Advertising

  2. Robert,

    >I am unable to get PNG reading to work using the javax.imageio.ImageIO
    >package.
    > I'm using PNG because ImageIO doesn't have a GIF writer
    > (I need to both read and write) and the JPEG writer blurs
    > my pictures in very ugly ways.


    you can find many libraries to read and write images here:
    http://www.geocities.com/marcoschmidt.geo/java-image-coding.html


    You can also try Imagero Reader: http://reader.imagero.com

    Note: next version of Imagero Reader will include possibility to manipulate
    JPEG images without quality loss.

    > Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException:
    > LUT has improper length!
    > at javax.imageio.ImageTypeSpecifier$Indexed.<init>(Unknown Source)
    > at javax.imageio.ImageTypeSpecifier.createIndexed(Unknown Source)
    > at com.sun.imageio.plugins.png.PNGImageReader.getImageTypes(Unknown
    > Source)
    > at com.sun.imageio.plugins.png.PNGImageReader.readImage(Unknown
    > Source)
    > at com.sun.imageio.plugins.png.PNGImageReader.read(Unknown Source)
    > at javax.imageio.ImageIO.read(Unknown Source)
    > at javax.imageio.ImageIO.read(Unknown Source)


    if you send me sample image I can try to investigate this problem.
    my email can be found here: http://reader.imagero.com/mailto.php

    Regards

    Andrei

    --
    Andrey Kuznetsov
    http://uio.dev.java.net Unified I/O for Java
    http://reader.imagero.com Java image reader
    http://jgui.imagero.com Java GUI components and utilities
     
    Andrey Kuznetsov, Jan 14, 2005
    #2
    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,219
  2. Davidski
    Replies:
    0
    Views:
    3,950
    Davidski
    Nov 5, 2004
  3. Replies:
    2
    Views:
    8,241
    Carfield Yim
    Feb 20, 2005
  4. tiewknvc9

    writing a "png" file with imageio

    tiewknvc9, Apr 4, 2006, in forum: Java
    Replies:
    3
    Views:
    703
    Oliver Wong
    Apr 4, 2006
  5. Christopher M. Lusardi
    Replies:
    3
    Views:
    217
    Alan J. Flavell
    Oct 19, 2003
Loading...

Share This Page