I want to create a web application that allow users to upload their image to the server. When they click send, their image will be uploaded to the server (multipart). Before saving, I want to make some operation with the image, so I decided to use ..
ImageIO.read(InputStream)
to get BufferedImage object
here is the code:
public static BufferedImage getBufferedImageFromMultipartFile(MultipartFile file)
throws APIException
{
BufferedImage bi = null;
try
{
bi = ImageIO.read(file.getInputStream());
}
catch (IOException e)
{
throw new APIException(ErrorCode.SERVER_ERROR, e);
}
return bi;
}
The problem is when I try to upload a picture that has height more than width such as 3264 x 2448 (height x width), the result always an image that has been rotated (2448 x 3264).
Is there any solution to solve this problem ?
Is this a bug or any defined API specification ?
Thx.
PS. sorry for my english :D