我有一個磁盤上的圖像,這是一個JPG文件。我想轉換並保存爲PNG並刪除原始JPG。什麼是最好的方式在java中做到這一點?java將JPG保存爲PNG
String justNameJpg = "something.jpg";
String justNamePng = ImageEditor.GetImageNameNoExtension(justName) + "." + "png";
java.awt.image.BufferedImage bufferedImage = ImageIO.read(new File(folder, justNameJpg));
ImageIO.write(bufferedImage, "png", new File(folder, justNamePng));
它絕不會傷害檢查.png格式首先檢查它是否存在於由ImageIO.getWriterFormatNames()返回的數組中, – 2011-05-17 16:37:54