Sorry, missed that part of the question-- Unfortunately, you're right on
track and retrieving width and height is really difficult with
java.awt.Image. :(

There is a better way though, I would investigate the new Java2D-Image I/O
API at:
http://developer.java.sun.com/developer/earlyAccess/imageio/

Basically, it will offer you a much cleaner route to creating a
BufferedImage.

BufferedImage bi = ImageIO.read( [File|ImageInputStream|InputStream|URL] );
getHeight()

----- Original Message -----
From: "Matthias Bauer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Levi Cook" <[EMAIL PROTECTED]>
Sent: Thursday, July 12, 2001 10:33 PM
Subject: Re: Image uploads


> Sorry for my thick-wittedness...
>
> But as soon as I have an Image object, I don't know how to determine the
> dimensions. I tried getWidth(null) and getHeight(null), but both
return -1.
>
> What am I missing?
>
> --- Matthias
>
> Levi Cook wrote:
>
> > Try one of these:
> >
> > String filename= "picture.gif";
> > Image offScreenImage= Toolkit.getDefaultToolkit().getImage(filename);
> >
> > URL imgUrl= new URL("http://www.yoururl.net/picture.gif";);
> > Image offScreenImage= Toolkit.getDefaultToolkit().getImage(imgUrl);
> >
> > HTH,
> > Levi
> >
> > ----- Original Message -----
> > From: "Matthias Bauer" <[EMAIL PROTECTED]>
> > To: "struts-user" <[EMAIL PROTECTED]>
> > Sent: Tuesday, July 10, 2001 3:56 AM
> > Subject: Image uploads
> >
> >
> >
> >>Hi there,
> >>
> >>I know the question is a little offtopic, but maybe somebody can provide
a
> >>
> > quick
> >
> >>answer anyway.
> >>
> >>I want to upload an image file with struts (this works well already).
But
> >>
> > before
> >
> >>storing the image in the database I want to check the width and height
and
> >>
> > the
> >
> >>type of the image (e. g. gif or jpg). Does anybody have an idea how I
can
> >>
> > easily
> >
> >>do this in Java?
> >>
> >>Thanks,
> >>
> >>--- Matthias
> >>
> >>
> >>
>
>
>
>

Reply via email to