Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve the dimensions of an image in the filesystem

How can I retrieve the dimensions of an image (typically jpeg, png, jpg and gif), in the local filesystem with Java?

like image 282
Addev Avatar asked Sep 21 '11 12:09

Addev


2 Answers

You can use java's image class to get image attributes. Here is the sample -

BufferedImage img = ImageIO.read(new File("imageFilePath"));
int height = img.getHeight();
int width = img.getWidth();
like image 113
Ankur Avatar answered Sep 29 '22 08:09

Ankur


how about this: getting image metadata

like image 22
Mark Bramnik Avatar answered Sep 29 '22 08:09

Mark Bramnik