1

I want to convert images from gif to jpeg by using im4java. There should be one gif and one ipeg picture after excution. But when I'v done this. There are 3 pictures. One is original gif, one is new nomarl jpeg, and other one is a crashed jpeg picture. Some pictures may cause this problems. Some may not. Is there anyone know why? Thanks


public static void convertImage(String srcPath, String newPath, String format)
throws Exception
{
    IMOperation op = new IMOperation();
    op.addImage(srcPath);
    op.addImage(newPath);
    System.out.println(op);
    ConvertCmd cmd = new ConvertCmd();
    cmd.run(op);
}
public static void changePictures(String format) throws Exception
{
    File file = new File("picture path");
    File pictureArray[];
    pictureArray = file.listFiles();
    int i;
    for(i = 0; i < pictureArray.length; i++)
    {
        convertImage(pictureArray[i].getAbsolutePath(), "picture path" + i + "." +          format, format);   
    }

}

1 Answers1

0

op.addImage(srcPath); here. Because there are more than one picture in a gif file.Try this op.addImage(srcPath+"[0]");