wood burning stoves
The moose likes Servlets and the fly likes cropping image in a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Servlets
Bookmark "cropping image in a servlet" Watch "cropping image in a servlet" New topic

cropping image in a servlet

Leonardo Ligas

Joined: Jan 25, 2011
Posts: 1

I have a problem with image cropping, i use jcrop and a java servlet.
in my servlet the image is cropped correctly but the top
left x and y coordinate of the result rectangle is always equal to the 0,0
coordinate of the source rectangle, example:

with this code:

doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
int x = new Integer( request.getParameter("x"));//
int y = new Integer( request.getParameter("y"));
BufferedImage outImage=ImageIO.read(new File("..........");
BufferedImage cropped=outImage.getSubimage(x, y, w, h);
ImageIO.write(cropped,ext, new File("...."));

I get always as result an image tath is cropped from x and y equal to 0 0.
i have checked x and y and they are not equal to 0.

Can you help me?
thank you
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: cropping image in a servlet
jQuery in Action, 3rd edition