title: How to create an image from an InputStream, resize it and save it?
body: <p>I have this code where i get an <code>InputStream</code> and create an image:</p>
  
  <pre><code>Part file;
  // more code
  try {
          InputStream is = file.getInputStream();
  
          File f = new File("C:\\ImagenesAlmacen\\QR\\olaKeAse.jpg");
  
          OutputStream os = new FileOutputStream(f);
          byte[] buf = new byte[1024];
          int len;
  
          while ((len = is.read(buf)) &gt; 0) {
              os.write(buf, 0, len);
          }
  
          os.close();
          is.close();
  
      } catch (IOException e) {
          System.out.println("Error");
      }
  </code></pre>
  
  <p>The problem is that I have to resize that image before i create if from the <code>InputStream</code></p>
  
  <p>So how to resize what I get from the <code>InputStream</code> and then create that resized image. I want to set the largest side of the image to 180px and resize the other side with that proportion.</p>
  
  <p><strong>Example:</strong></p>
  
  <p>Image = <code>289px * 206px</code>
  Resized image = <strong>180px</strong><code>* 128px</code></p>