본문 바로가기

STUDY/Java

Java | MultipartFile image width와 height 알아내기

private void checkImageSize(MultipartFile file) {
  try {
    BufferedImage bufferedImage = ImageIO.read(file.getInputStream());
    int width = bufferedImage.getWidth();
    int height = bufferedImage.getHeight();
    System.out.println(String.format("width = %d height = %d", width, height));
  } catch (IOException e) {
  	e.printStackTrace();
  }
}