我正在构建一个程序,将给定的图像压缩并保存为JPEG格式。这是我收到的错误信息:
Exception in thread "main" javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(Unknown Source)
at JPEGCompression.main(JPEGCompression.java:23)
这是我的主函数:
public class JPEGCompression {
public static void main(String[] args) throws IOException{
String imageFile = "/tmp/garden.png";
BufferedImage i = ImageIO.read(new File(imageFile)); // this line produces the error
showImage("Original Image", i);
compressAndShow(i, 0.7f);
}