java获取网络图片的宽和高

/**
     * 获取网络图片的宽和高
     * @param url
     * @return
     */
    public static String getWidthAndHeight(String url) {
        try {
            InputStream is = new URL(url).openStream();
            BufferedImage sourceImg = ImageIO.read(is);
            int width = sourceImg.getWidth();
            int height = sourceImg.getHeight();
            return width+"*"+height;
        } catch (IOException e) {
            log.error("获取图片宽高失败");
            e.printStackTrace();
        }
        return "";
    }

 

    原文作者:liangks@email.cn
    原文地址: https://blog.csdn.net/qq_34706514/article/details/82658264
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞