• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get height and width of uploaded image  RSS feed

 
Dan Arbo
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am building a web app that allows the user to upload images.
They are then displayed in a grid, and they must fit inside their box, so one dimension fits the box and the other is scaled.
To do that I store the image in the DB.

It was working fine on my laptop, because I have access to the file system. Once I uploaded it on the servers of a hosting company it stopped working, because there is no access to the file system.

They also provide an FTP directory, so I changed my app to FTP files to that directory. Now it doesn't work anymore.
Here's what I am doing, if anybody can spot what is wrong, I would appreciate. Thanks in advance...

I am using commons.fileupload and commons.net



No exception is thrown at



but image is null, and I get a null pointer exception when I try to get width and height.

I am sure that the InputStream object is not null or corrupted because it's FTP'ed ok, and it can be opened from the remote location.

Reading the image from the file system is not an option...

Thanks!

 
Dan Arbo
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found a solution, in case anyone ever has the same problem, using AWT BufferedImage.

FileItem fileItem is the image returned by the form which uploads the file

 
Randall Twede
Ranch Hand
Posts: 4690
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pretty good for a greenhorn
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!