title: Meta data is missing after creating BufferedImage
body: <p>I am writing meta data inside PNG image using below code:</p>
  
  <pre><code>public synchronized static byte[] writeMetaDataInPNGImage(BufferedImage buffImg,
                                                                        String key, String value)
  
  {
      byte[][] image = null;
      try
      {
  
  
          ImageWriter writer = ImageIO.getImageWritersByFormatName("png").next();
  
          ImageWriteParam writeParam = writer.getDefaultWriteParam();
          ImageTypeSpecifier typeSpecifier = ImageTypeSpecifier
              .createFromBufferedImageType(BufferedImage.TYPE_INT_RGB);
  
          // adding metadata
          IIOMetadata metadata = writer.getDefaultImageMetadata(typeSpecifier, writeParam);
  
          IIOMetadataNode textEntry = new IIOMetadataNode("tEXtEntry");
          textEntry.setAttribute("keyword", key);
          textEntry.setAttribute("value", value);
          IIOMetadataNode text = new IIOMetadataNode("tEXt");
          text.appendChild(textEntry);
  
          IIOMetadataNode root = new IIOMetadataNode("javax_imageio_png_1.0");
          root.appendChild(text);
          int width = buffImg.getWidth();
          int height = buffImg.getHeight();
          metadata.mergeTree("javax_imageio_png_1.0", root);
  
  
  
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
  
          ImageOutputStream stream = ImageIO.createImageOutputStream(baos);
          writer.setOutput(stream);
          writer.write(metadata, new IIOImage(buffImg, null, metadata), writeParam);
          stream.close();
  
          return baos.toByteArray();
          // return ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
  
      }
      catch (Exception e)
      {
          System.out.println("Exception while writing \t " + e.getMessage() + "  :: "
                             + e.getStackTrace());
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p>After writing meta data I am returning byte array with meta data and image data.</p>
  
  <pre><code>byte[] pngjdata = writeMetaDataInPNGImage(img.getAsBufferedImage(),"key", "hello");
  </code></pre>
  
  <p>If I save the image with  <code>pngjdata[]</code> I am able to see the meta data inside image, but if I create <code>BufferedImage</code> from this byte array and save it I am not seeing written meta data.</p>
  
  <pre><code>InputStream in1 = new ByteArrayInputStream(pngjdata);
  BufferedImage brImage = ImageIO.read(in1);
  </code></pre>
  
  <p>Why is <code>brImage</code> not having the meta data written by me?</p>