title: Image Compression for jpg format
body: <p>This is a question on top of this Question :</p>
  
  <p><a href="https://stackoverflow.com/questions/28439136/java-image-compression-for-any-image-formatjpg-png-gif/42945905">java image compression for any image format(jpg, PNG, gif)</a></p>
  
  <p>The Code is Here :</p>
  
  <pre><code>File input = new File("digital_image_processing.jpg");
  BufferedImage image = ImageIO.read(input);
  
  File compressedImageFile = new File("compress.jpg");  
  OutputStream os = new FileOutputStream(compressedImageFile);
  
   Iterator&lt;ImageWriter&gt;writers = ImageIO.getImageWritersByFormatName("jpg");
   ImageWriter writer = (ImageWriter) writers.next();
  
   ImageOutputStream ios = ImageIO.createImageOutputStream(os);
   writer.setOutput(ios);
  
   ImageWriteParam param = writer.getDefaultWriteParam();
  
   param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
   param.setCompressionQuality(0.05f);
  
   writer.write(null, new IIOImage(image, null, null), param);
  </code></pre>
  
  <p>Problem :</p>
  
  <p>I have tried the above code , the image compression happens</p>
  
  <p>Original Size : 2209 Kb Actual Size : 633 Kb Compression Quality : 0.98f</p>
  
  <p>But the image doesn't look the same after compression , the image is very glossy and for some images its difficult to read the image and get the details out of it</p>
  
  <p>Not able to Upload the Image here as it's more than 2 MB. Please find the image on this URL : <a href="https://ibb.co/jgO2WF" rel="nofollow noreferrer">https://ibb.co/jgO2WF</a> .</p>
  
  <p>Please save it as jpg format and try to compress the image using above logic and check the image before and after compression. Can it be possible to make it less glossy or more readable?</p>
  
  <p>When is replace the format with jpeg instead of jpg and try to compress a jpeg image , it works like a beauty. </p>