Solved

Get Image Width and Height values

Posted on 2008-06-10
3
1,304 Views
Last Modified: 2013-11-24
I am just learning JSP, and I have been trying to get this working all day to no avail.  What I am trying to do is, using an image's path on my physical drive like "C:\myfolder\myimage.jpg", display on a webpage the width and height of the image.  I did not need to manipulate the image, so I thought this might be easy.  If anyone has some working code in JSP to solve this that would be amazing.  I am not picky right now if it is using a scriptlet, tags, or however it can be done  Thanks!
0
Comment
Question by:js_vaughan
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 21753910
You can do something like:
BufferedImage bi = javax.imageio.ImageIO.read(new File("C:/myfolder/myimage.jpg"));
int w = bi.getWidth();
int h = bi.getHeight();

Open in new window

0
 
LVL 10

Author Closing Comment

by:js_vaughan
ID: 31465877
I figured it was going to be simple, just wasnt getting it right =P

Thanks!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 21754088
:-)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question