title: Java - Compressing an Image without Quality Loss
body: <p>I have a jpeg Image that is 2.1mb in size. I am attempting to compress the Image data as much as possible. Possibly below 1mb. Currently I have done some research on the subject and I have written some code to attempt to compress the data. I have stumbled upon this Answer:</p>
  
  <p><a href="https://stackoverflow.com/a/4535883/3011902">https://stackoverflow.com/a/4535883/3011902</a></p>
  
  <p>Based on this I have converted an Image file to a byte array, and then converted the byte array to its binary equivalent. Then I use run length encoding on the binary data. This makes the size larger however.</p>
  
  <p>I have tried to convert the file to a png. But that increased the file size dramatically; 9mb.  </p>
  
  <p>So what is the best way in Java to compress and Image files size without quality loss?</p>