我正在尝试使用Java代码从URL下载高分辨率图像。 但是下载到本地计算机后,图像的分辨率降低了。 我正在使用下面的代码下载,有人可以建议我在哪里出错。
String url = "https://s3.eu-central-1.amazonaws.com/euroc-inspect/processing/E1039585_TOP_3_1.jpg";
URL liveUrl = new URL(url);
BufferedImage bimg = ImageIO.read(liveUrl);
int width = bimg.getWidth();
int height = bimg.getHeight();
ImageIO.write(bimg, "jpg", new File("E:/img.jpg"));
System.out.println("Image Saved");
答案 0 :(得分:0)
获得完全相同的分辨率:
2048x1425
ImageDownloader.java :
import java.net.URL;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
public class ImageDownloader {
public static void main(String[] args) throws Exception{
if(args.length<2) {
System.out.println("Usage: ImageDownloader <url> <localfilename>");
System.exit(1);
}
String url = args[0] ;
String targetFile = args[1];
URL liveUrl = new URL(url);
BufferedImage bimg = ImageIO.read(liveUrl);
int width = bimg.getWidth();
int height = bimg.getHeight();
ImageIO.write(bimg, targetFile.substring(targetFile.indexOf(".")), new File(targetFile));
System.out.printf("Image %s saved. (size: %dx%d)",targetFile, width, height);
}
}