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

    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 javax.imageio.ImageIO;

    public class example {
    public static void main(String[] argv) throws Exception {
    BufferedImage bufferedImage = 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 10:00 AM.

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


    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, 09:01 AM
  2. convert byte[] to image
    By brijesh.baser in forum Java Servlet
    Replies: 0
    Last Post: 03-13-2009, 02:44 PM
  3. convert Image to pixels
    By nithya.p in forum New To Java
    Replies: 0
    Last Post: 03-05-2009, 03: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, 02:32 PM
  5. Replies: 0
    Last Post: 07-02-2008, 09: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