机器学习和生物信息学实验室联盟
标题:
Java获取图片的尺寸
[打印本页]
作者:
souven
时间:
2013-8-29 13:44
标题:
Java获取图片的尺寸
用Java实现获取一张图片的尺寸,示例用下:
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class img {
/**
* example of getting the information(width,height) of a image
* @throws IOException
*/
public static void main(String[] args) throws IOException {
String imgPath = "D:\\1.jpg"; //the path of the image file
BufferedImage bufferedImage = ImageIO.read(new File(imgPath));
int width = bufferedImage.getWidth();
int height = bufferedImage.getHeight();
//the variables width,height is what we want
}
}
复制代码
代码过于简单,此帖甚虚,欢迎拍砖。
作者:
endual
时间:
2013-10-11 00:05
这个一般有什么用?
欢迎光临 机器学习和生物信息学实验室联盟 (http://123.57.240.48/)
Powered by Discuz! X3.2