• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts FormFile - image dimentions

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am using an org.apache.struts.upload.FormFile object.
The clients are going to be uploading images.
I have checked the API docs on the FormFile.
One of the restrictions of the images that are being uploaded, are the dimentions. The image cannot be too small, or too large.

I have no idea how to check the dimentions of images, using the FormFile object..

Does anyone know how I can grab the image dimentions?

Cheers

Carl
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to read the image into a java.awt.Image object like so:



Piece of cake
 
Carlo Moore
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats great. Thanks Kerry.

I also found an alternative way to find the image size.
I created a hidden layer, in html. In that hidden layer, I added an image, src="". I had some javascript that set the src of the img to the path the user would be entering via the file browes button.

if the path points to a valid image, you would be able to grab the image dimentions from that img. (document.form.image.width/height.)

I know its not the best way of doing things. I will update my code to use the awt package..

Cheers

Carl
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's pretty neat, I never thought of using the file upload to set an image on the page so that it can be previewed ( or used otherwise ).
reply
    Bookmark Topic Watch Topic
  • New Topic