title: Resize a byte array image in pixels
body: <p>I have an image stored as a byte array. Regardless how large the size, I want to always resize it down to 100x100 pixels. </p>
  
  <p>I am trying to convert the byte array into a bufferedimage, resize and save it back as a bytearray. But with the following code, the images no longer appear on my page. </p>
  
  <pre><code>byte[] pict; // this array contains the image
  BufferedImage bufferedImage;
  
  ByteArrayInputStream bais = new ByteArrayInputStream(pict);
  try {
      bufferedImage = ImageIO.read(bais);
      bufferedImage = Scalr.resize(bufferedImage, 100);
  
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ImageIO.write( bufferedImage, "jpg", baos );
      baos.flush();
  
      pict = baos.toByteArray();
      baos.close();
  
  } catch (IOException e) {
      throw new RuntimeException(e);
  }
  OutputStream o = response.getOutputStream();
  o.write(pict); 
  </code></pre>