Apache FileUpLoad and BufferedImage?

Hello,

I am planning to use the apache fileupload tool, to access images posted to a servlet.

The servlet accesses the files using:

List items = upload.parseRequest(req);

while(iter.hasNext()){
   FileItem item = (FileItem) iter.next();
}

My plan was to create a thumbnail of the orginal image, and this and orginal image.

Could anyone advise if I could possibly create an BufferedImage object or Image object from the item variable above, and then reduce the image size using the bufferedimage?

Thank you
AntoniRyszardAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rrzCommented:
You can use.
BufferImage bi = ImageIO.read(item.getInputStream());
0
AntoniRyszardAuthor Commented:
Thanks I'll try this,

Do you think this would work for gif and png images as well?

Could you offer any advise in creating an thumbnails from the orginal.

I thought it would be difficult to make all the thumbnails one size automatically. Perhaps I should take a width, height of the orginal image and determine from this if I should scale down by 50%, 25%.

Thanks
0
rrzCommented:
Scaling can be done a number of ways  
java.awt.geom.AffineTransform  has   scale(double sx,double sy)  
or  
java.awt.Image   has  getScaledInstance(int width,int height,int hints)

I don't which one the experts are using.  What formats ?  jpg ?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rrzCommented:
>Do you think this would work for gif and png images as well?
Are you using Java 5 ?  
ImageIO has readers for jpg, png, and gif .  Writers for   jpg and png,  I am not sure about gif. You might have to use Acme.com  package.  
Hopefully we will get some help from experts.  I am not real  expert in Image code.  
0
AntoniRyszardAuthor Commented:
Thanks

I am not very use to the Image or AffineTransform classes. I will look into these.

Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.