How to use JHlabs image filter in spring MVC project

First you have to create image filter class like this

public class ImageFilter {
public void applyFilter(MultipartFile multipartFile){
String destination = “/your/file/destination/folder/”;
try {
GaussianFilter filter = new GaussianFilter();
filter.setRadius(8.5f);
BufferedImage imBuff = ImageIO.read(multipartFile.getInputStream());
filter.filter(imBuff, imBuff);

File outputfile = new File(destination+”image.jpg”);
ImageIO.write(imBuff, “jpg”, outputfile);

} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

And then modify the request mapping method for file upload in your controller like this

@RequestMapping(method = RequestMethod.POST)
public String fileUploaded(Model model, @Validated File file,
BindingResult result) {

String returnVal = “successFile”;
if (result.hasErrors()) {
returnVal = “file”;
} else {
MultipartFile multipartFile = file.getFile();
SaveFileToFolder save = new SaveFileToFolder();
save.saveFile(multipartFile);
}
return returnVal;
}

After running the blurred image will be stored in the location you specified.