title: Increasing Resolution and Reducing Size of an Image in Java
body: <p>When I first asked this, I included as much information as I could, since I never know what will help someone if they can give m a solution, but from the answers, it seems I didn't make my point clear.</p>
  
  <p>I'm leaving the original text at the bottom and shortening this.  I hope that makes it clear.</p>
  
  <p>I am working with images returned to me from another program.  I can get an image that's, for example, 8x10 at 72 DPI or the same image at 16x20, also at 72DPI.</p>
  
  <p>I'm working in Java.  What I'd like to do is take the 16x20 image and resize it.  If possible, I'd like to just change the file so instead of being 16x20 at 72DPI, it's 8x10 at 144DPI.</p>
  
  <p>I know that it's still the same number of pixels, but viewers will say how big an image is and what the DPI is and also some open an image to its full size, so I'd rather them treat the 16x20 as a smaller image with a higher resolution.</p>
  
  <p>Can I do that in Java?  Will I lose any data?  How would I do it - can I just change the metadata in the png or jpg file?</p>
  
  <p>-----(original question below here)-----</p>
  
  <p>I've seen a few questions that come close to this, but this is a little different.</p>
  
  <p>I know you can <a href="https://stackoverflow.com/questions/6390964/decrease-image-resolution-in-java">decrease image resolution</a> with an image in Java (<a href="https://stackoverflow.com/questions/1324106/jai-change-jpeg-resolution">also here</a>).  Any searches I've done have been concerned with decreasing the resolution of an image.</p>
  
  <p>I have the opposite problem.  I'm working with an image that I'm getting back in 72DPI.  The advantage is I can increase the size of the picture, so I could make the size 100%, 200%, 400% and so on.  All images are at 72DPI, so if I use 200% for the zoom, then open the image in a viewer and make it the same size as the 100% image, I am seeing a better resolution.</p>
  
  <p>For clarity - I am getting an image from someone else, it could be generate from a PDF or picture, but I am <strong>given</strong> the image from another program.  No matter what I do, this image is at 72DPI.  I can't change that, but I can specify the size at 200% and it still comes back at 72DPI, just twice as big and with more detail.</p>
  
  <p>I'm no graphics expert and this is the first time I've done any programming that uses graphics.  The output could be jpg or png, so the format isn't that important.  (I could probably also use other formats if needed.)</p>
  
  <p>Let's say the original image is a photo - 8" x 10", and at 72 DPI.  If I ask for a 200% zoom, I get a 16" x 20" image at 72DPI.</p>
  
  <p>Can I, within Java, change that larger 16" x 20" 72DPI image to a 144DPI image that's 8" x 10" without losing data?  In other words, double the DPI, but cut the size in half?</p>
  
  <p>And, most importantly, can I do it without losing resolution?  (I would think that can be done.)</p>