-3

I have a form to upload image, so what I want is that whenever a user uploads any type of image (png/jpg etc) convert that image into jpg and save that image to storage from Multipart.

john
  • 17
  • 3

1 Answers1

0

I think you can have a response with this previous question :

Image conversion in JAVA

File inputFile = new File("/fileOfYourForm.png");
File outputFile = new File("NewImage.jpg");
try (InputStream is = new FileInputStream(inputFile)) {
    BufferedImage image = ImageIO.read(is);
    try (OutputStream os = new FileOutputStream(outputFile)) {
        ImageIO.write(image, "jpg", os);
    } catch (Exception exp) {
        exp.printStackTrace();
    }
} catch (Exception exp) {
    exp.printStackTrace();
}
Fizik26
  • 753
  • 2
  • 10
  • 25