从URL保存exif数据下载图像

时间:2017-12-17 13:28:59

标签: java

我试图将带有exif数据的图像从URL下载到我的电脑,问题是exif数据在图像下载后消失了。

这里是我使用的代码

public static void downloadImage(String str) {
    try {
        URL url = new URL("https://upload.wikimedia.org/wikipedia/commons/6/68/Goldmantelziesel.jpg");
            BufferedImage img = ImageIO.read(url);
            File file = new File("F:\\Photos\\ww123\\"+str+".jpg");
            ImageIO.write(img, "jpg", file);
    } catch (MalformedURLException e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    } catch (IOException e) {
        System.out.println(e.getMessage());
    }
}

0 个答案:

没有答案
相关问题