Link to home
Start Free TrialLog in
Avatar of KrisM82
KrisM82

asked on

Uploading images & Image manipulation

Hi everyone

What I am trying to do is this:

I want to have a JSP where the user browses for an image, and then clicks a submit button, I then want the selected image to be uploaded and stored...

My questions are:

1 - Can the image be stored in a MySQL database or does it have to be uploaded to a directory

2 - Is there a way to manipulate the image and make thumbnails etc in a Servlet?

3 - Is there a java API for doing things like this (if yes any chance of a url)?

Many thanks

Kris


Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

1) I would store the image in a directory.  It makes it easier to show the image to the user (via an IMG html tag), and makes it easier to backup your data (as your database doesn't contain loads of BLOB fields)
2) Yeah, sure...  Load the image in to a BufferedImage, call getScaledInstance, and write the image back out again using the JPG compression routines (http://javaalmanac.com/egs/javax.imageio/BasicImageRead.html and http://javaalmanac.com/egs/javax.imageio/JpegWrite.html)
3) See 2  ;-)

Tim
Oh, and http://javaalmanac.com/egs/java.awt.image/CreateTxImage.html for the "making it smaller" bit ;-)
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KrisM82
KrisM82

ASKER

Cool thanks for the help exactly what I was looking for :0)
Good luck! :-)

Tim
Avatar of KrisM82

ASKER

Having a few problems with this still, any chance you could give me a hand if i post the source code?