title: How can I compress jpeg images in Java without losing any metadata in that image?
body: <p>I want compress jpeg files using Java.  I do it like this:</p>
  
  <ol>
  <li>Read the image as <code>BufferedImage</code></li>
  <li>Write the image to another file with compression rate.</li>
  </ol>
  
  <p>OK, that seems easy, but I find the ICC color profile and the EXIF information are gone in the new file and the DPI of the image is dropped from 240 to 72. It looks different from the origin image. I use a tool like preview in OS X. It can perfectly change the quality of the image without affecting other information. </p>
  
  <p>Can I done this in Java? At least keep the ICC color profile and let the image color look the same as the origin photo?</p>