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);
}
}
op.addImage(srcPath); here. Because there are more than one picture in a gif file.Try this op.addImage(srcPath+"[0]");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.