Java converts GIF images to PNG format

I have to build a java servlet to receive images and return images converted to PNG format How can I do this?

Thank you in advance!

Solution

Try this:

package demo;

import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;

public class Main {
    public static void main( String [] args ) throws IOException { 
        File input = new File("input.gif");
        File output = new File("output.png");

        ImageIO.write( ImageIO.read( input ),"png",ouput);
    }
}

Read imageio

Of course, you may want to read and write from the stream

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>