Hi, well, the question should be split into two subquestions: 1) how to serve requests for images 2) how to manipulate images before sending them back to clients
1. The first is simple: create a servlet which receives an identifier (the name of the image to generate). It can then get the bytes of the image either from a database or from a local file on the server. Before actually sending the image bytes back to client, you set the content-type header to the appropriate type (image/jpeg, image/gif). Example: You have this line in a html/jsp file: <img src="/servlet/imageServlet?imageID=apples.gif" border=0/> The servlet imageServlet would 1. retrieve the bytes of the given image 2. set the content-type 3. and finally, it writes all the bytes into the OutputStream available through the HttpServletRequest which is passed in as an argument by the servlet runner. 2. It is relatively easy to manipulate images with Java. Firstly I would create a java.awt.Image out of the bytes of the image: byte[] bytes = getImageBytes(imageName); // this is just an imaginary method name Image img = java.awt.Toolkit.getDefaultToolkit().createImage(bytes); You then get the Graphics object for this Image, and do the necessary manipulations on the Graphics. Finally you get the bytes of the Image using an ImageConsumer and send them back to the client. I haven't done such image manipulation yet, but it should work theoretically :) Cheers, J�nos |-----Original Message----- |From: yilmaz [mailto:[EMAIL PROTECTED]] |Sent: Tuesday, March 12, 2002 3:54 PM |To: Tomcat Users List |Subject: image manipulating via servlets on tomcat4 | | |Hi everybody, |I am using tomcat4 on win 2000. |I have searched all the archives and almost all websites related with java, |to no avail. |My problem is manupulating images via servlets on Tomcat. |In fact , there are tons of examples on the internet and on the archives |which shows |how to load an image from a local file and send to the browser, or |dynamically |generate a gif , or jpg image and send it to the user. Up to here , |everything is allright. |But , it seems that there is no way to load an image from a file (at |server), write some text on it |or edit that image on hand, finally send it to hte browser as a new image. |I tried almost every way, in vain :( |I hope, someone overthere, an expert, be nice enough to answer my question, |though my |question might sound a little bit offtopic. |Looking forward to your help hopefully. |Cheers :) | | | |-- |To unsubscribe: <mailto:[EMAIL PROTECTED]> |For additional commands: <mailto:[EMAIL PROTECTED]> |Troubles with the list: <mailto:[EMAIL PROTECTED]> | | -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>
