I am working on a web application that:
- Uploads a JPEG image
- extracts a zone from it (using coordinates)
- and resizes the zone extracted, without loosing image quality .
I used this code to do this:
//method to extract an image
def extractedImage=exractImageRect( imageFile , x , y , h , w)
ImageIO.write(extractedImage, "PNG", new File("C:\\Users\\Ma\\Documents\\out.png"));
int type = extractedImage.getType() == 0? BufferedImage.TYPE_INT_ARGB : extractedImage.getType();
//resize the image
resizedImage =resizeImage(extractedImage, type ,w*2 , h*2)
But using this code, the resized image has a very low quality. I also used RenderingHints: same problem.
So my question is: What is the best way to keep the image quality, while using the height and width of the original image, which has 300dpi and 2479 width , 3508 height?