我需要将 jpeg 图像转换为 jfif 格式,这是因为我需要发送彩信数据。谁能告诉我如何使用java转换它。
最佳答案
你尝试过ImageIO吗? 我真的不知道它是否有效,而且我现在无法测试它(因为我不在家里),但你可以使用以下方法获取 ImageIO 图像格式:
String[] formatNames = ImageIO.getReaderFormatNames();
正如我所说,我无法测试此代码,但您可以尝试:
try {
File input = new File("srcImage.jpeg");
BufferedImage image = ImageIO.read(input);
File output = new File("dstImage.jfif");
ImageIO.write(image, "jfif", output);
System.out.println("Your image has been converted successfully");
} catch(Excpetion e){
System.out.println("Error:"+e.getMessage());
}
说实话,我认为这行不通。也许您可以尝试第 3 方插件(如果存在)。
关于java - JPEG 到 JFIF 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4645809/