This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes I/O and Streams and the fly likes image dimension Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "image dimension" Watch "image dimension" New topic
Author

image dimension

jonathan Greens
Ranch Hand

Joined: Apr 07, 2004
Posts: 139
hi folks,
is it possible to get the image dimension from an image file?
my webapp allows user to upload image file and then display it. The issue here is that I need to shrink the image file proportionally to create a thumbnail and display these thumbnails in a table.
thanks!!
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
You can load it as a BufferedImage with ImageIO (j2se 1.4+) and get the dimensions with the BufferedImage getWidth/Height methods and use this to scale the images to final size. If using an older loading method (eg, ImageIcon, Toolkit getImage) you may need an ImageObserver (any Component) to get the dimensions.
 
Don't get me started about those stupid light bulbs.
 
subject: image dimension