How can I write a GIF image?

John Zukowski

Patent restrictions didn't allow a GIF writer to be part of the Java platform prior to JDK 6. With the recent expiration of the Unisys patent, JDK 6 includes support.


import javax.imageio.*;
import java.io.*;
import java.awt.image.*;
import java.util.*;

public class ToGif {
  public static void main(String args[]) throws IOException {
    if (args.length == 0) {
      System.err.println("Missing input filename");
      System.exit(-1);
    }
    String name = args[0];
    File inputFile = new File(name);
    BufferedImage input = ImageIO.read(inputFile);
    File outputFile = new File(name+".gif");
    ImageIO.write(input, "GIF", outputFile);
  }
}
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact