簡體   English   中英

使用Java代碼將圖像下載到本地計算機后,圖像分辨率降低

[英]Image Resolution is decrease wile downloading Image to local machine using Java code

我正在嘗試使用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");

獲得完全相同的分辨率:

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);
    }
}

原始圖像 在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM