I have a program that sends the image from frontend (angularjs) to java controller. In controller I am geting a byte array. I can save this image but I would like to resize this image before I saveing. The problem is that I want to set fixed height of the picture, and the change of width should take place proportionately to the height. This procedure should be universal so that it can be applicable to different photos.
Below is my code:
@RequestMapping(value = "/rest/bookImage", method = RequestMethod.POST)
public @ResponseBody MessageDTO UploadFile(
MultipartHttpServletRequest request, HttpServletResponse response) {
Iterator<String> itr = request.getFileNames();
MultipartFile file = request.getFile(itr.next());
FileOutputStream fos;
fos = new FileOutputStream(urlImage);
fos.write(file.getBytes());
fos.close();
}