I'm using java to crop image when upload file, I set value and to try to crop but is not get correct size of image as I expected
This my code: (updated)
private BufferedImage cropImageSquare(byte[] image) throws IOException {
InputStream in = new ByteArrayInputStream(image);
BufferedImage originalImage = ImageIO.read(in);
System.out.println("Original Image Dimension: "+originalImage.getWidth()+"x"+originalImage.getHeight());
BufferedImage croppedImage = originalImage.getSubimage(300, 150, 500, 500);
System.out.println("Cropped Image Dimension: "+croppedImage.getWidth()+"x"+croppedImage.getHeight());
return croppedImage;
}
my photo:
I want to crop image as above image (red line) but my code is seem incorrect.
How to crop image as expect?
See Question&Answers more detail:os