This may be a repost, I may have accidently sent a previous reply before I
finished typing. :)

Anyway, I missed the original point of your question in my earlier reply.
Unfortunately (& fortunately), you aren't being thick-witted at all-- the
API is simply that limited :(

In your shoes, I would definitely check out the Java2D-Image I/O API at:
http://developer.java.sun.com/developer/earlyAccess/imageio/

Basically, it offers you a quicker/simpler route to producing a
BufferedImage, which has the simplified getHeight() and getWidth() methods
you're interested in.

In code, it would go something like this:

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

HTH,
Levi


----- 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