Results 1 to 2 of 2
  1. #1
    zhl2002 is offline Member
    Join Date
    May 2010
    Posts
    1
    Rep Power
    0

    Default how to convert png to pgm image

    hi. i have created an image using java. it is in png format but i would like it to be in pgm format. anyone can help to edit my code (which fails to run)? thanks!

    import java.awt.image.BufferedImage;
    import java.io.File;
    import javax.imageio.ImageIO;
    import java.io.ByteArrayOutputStream;

    public class example {
    public static void main(String[] argv) throws Exception {
    BufferedImage bufferedImage = ImageIO.read(new File("C:\\Documents and Settings\\home user\\Desktop\\test6\\image.png"));

    ImageIO.write(bufferedImage, "pgm", new File("C:\\Documents and Settings\\home user\\Desktop\\test6\\image.pgm"));
    }
    }
    Last edited by zhl2002; 05-31-2010 at 09:00 AM.

  2. #2
    Maxideon is offline Member
    Join Date
    Jun 2010
    Posts
    28
    Rep Power
    0

    Default

    You'll need a pgm ImageWriter plugin for that code to work. You'll have to download that from a 3rd party. I believe JAI-ImageIO has a pnm ImageWriter.

Similar Threads

  1. How to convert image to text
    By asabdo in forum New To Java
    Replies: 9
    Last Post: 12-13-2010, 08:01 AM
  2. convert byte[] to image
    By brijesh.baser in forum Java Servlet
    Replies: 0
    Last Post: 03-13-2009, 01:44 PM
  3. convert Image to pixels
    By nithya.p in forum Java Tip
    Replies: 0
    Last Post: 03-05-2009, 02:23 PM
  4. how to convert an image in to pixels
    By Shyam Singh in forum New To Java
    Replies: 7
    Last Post: 09-22-2008, 01:32 PM
  5. Replies: 0
    Last Post: 07-02-2008, 08:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •