+public String pictureUpload(MultipartFile mpfGet,String userName,int x1,int y1,int w,int h) {
+
+// getting image and seeing output
+MultipartFile mpf = mpfGet;
+String extension = ".png";
+// inserting image to the server
+Rectangle rect = new Rectangle();
+rect.height = h;
+rect.width = w;
+try {
+BufferedImage src = ImageIO.read(mpf.getInputStream());
+BufferedImage dest = src.getSubimage(x1, y1, rect.width, rect.height);
+String rootPath = "/usr/local/var/www/";
+File outputPath = new File(rootPath + "abc"+ extension);
+ImageIO.write(dest, "png", outputPath);
+} catch (IOException e) {
+
+}
+return pictureName;
+}
+ Dependencys
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>