机器学习和生物信息学实验室联盟

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2555|回复: 1
打印 上一主题 下一主题

Java获取图片的尺寸

[复制链接]
跳转到指定楼层
楼主
发表于 2013-8-29 13:44:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
用Java实现获取一张图片的尺寸,示例用下:
  1. import java.awt.image.BufferedImage;
  2. import java.io.File;
  3. import java.io.IOException;
  4. import javax.imageio.ImageIO;

  5. public class img {

  6.         /**
  7.          * example of getting the information(width,height) of a image
  8.          * @throws IOException
  9.          */
  10.         public static void main(String[] args) throws IOException {
  11.                 String imgPath = "D:\\1.jpg"; //the path of the image file
  12.                 BufferedImage bufferedImage = ImageIO.read(new File(imgPath));
  13.                 int width = bufferedImage.getWidth();
  14.                 int height = bufferedImage.getHeight();
  15.                 //the variables width,height is what we want
  16.         }

  17. }
复制代码
代码过于简单,此帖甚虚,欢迎拍砖。
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享
回复

使用道具 举报

沙发
发表于 2013-10-11 00:05:00 | 只看该作者
这个一般有什么用?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

机器学习和生物信息学实验室联盟  

GMT+8, 2024-5-3 04:48 , Processed in 0.068908 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表