Solved

Get Image Width and Height values

Posted on 2008-06-10
3
1,303 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Maven Project: Hibernate Dependencies Conflict 10 38
check java version using powershell 13 170
web project error add remove 1 28
Setup GlassFish 4 21
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

839 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