Source Code : Convert colour JPEG to PGM format

Convert colour JPEG to PGM format


import java.io.*;
import javax.media.jai.*;
import javax.imageio.ImageIO;
public class ConvertSpeed
{ private static String inputFileName = "C:\\Program Files\\balloon.jpg";
private static String outputFileName = "C:\\Program Files\\balloon.pgm";
 public static void main(String args[])
{ System.out.println("Start....");
File inputFile = new File(inputFileName);
 RenderedOp src = JAI.create("fileload", inputFile.getAbsolutePath()); FileOutputStream stream = null;
try
{
 stream = new FileOutputStream(outputFileName);
ImageIO.write(src, "pgm", stream);
 }

 catch(IOException ioe)
{
System.out.println(ioe);
 }
System.out.println("Done.");
 } }