import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
public class ImageSizeUtil {
public static void main(String[] args) {
String imageUrl = "https://example.com/image.jpg"; // 替换成你的网络图片路径
try {
URL url = new URL(imageUrl);
BufferedImage image = ImageIO.read(url);
int width = image.getWidth();
int height = image.getHeight();
System.out.println("图片宽度:" + width + " 像素");
System.out.println("图片高度:" + height + " 像素");
} catch (IOException e) {
e.printStackTrace();
}
}
}
08-18
3151
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-06
2458
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)