aspose file tools*
The moose likes Servlets and the fly likes Width and height of Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Width and height of Image" Watch "Width and height of Image" New topic
Author

Width and height of Image

hasan wasif2k1
Greenhorn

Joined: Jan 13, 2001
Posts: 26
Trying to retreive image width and height but no success.
A Code is here but with errors. Pls help soon.
<%@ page import="java.awt.*" %>
<%@ page import="java.awt.image.*" %>
<%
Image img=Toolkit.getDefaultToolkit().getImage("a.jpg");
int w=img.getWidth();
%>
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
Images are loaded by a separate Thread so you can not immediately get the width and height. A MediaTracker will help you there.
You can NOT put an image into a page from inside a JSP, all you can do is write the code that makes the browser load the image - look at the html tag for <img> - it takes a URL because the browser starts a separate Thread to load the image.
Bill

------------------
author of:


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Width and height of Image
 
Similar Threads
Dertermine Image Width & Height
lagging on loading image
trouble with remove item fro shopping cart
Problem in importing html file in jsp
xsl:variable into xsl-fo elements...