title: How to compress images in CodeIgniter, yet do not change their dimensions?
body: <p>I have a site where users can upload images. I process these images directly and resize them into 5 additional formats using the CodeIgniter Image Manipulation class. I do this quite efficiently as follow:</p>
  
  <ul>
  <li>I always resize from the previous format, instead of from the original</li>
  <li>I resize using an image quality of 90% which about halves the file size of jpegs</li>
  </ul>
  
  <p>The above way of doing things I implemented after advise I got from another question I asked. My test case is a 1.6MB JPEG in RGB mode with a high resolution of 3872 x 2592. For that image, which is kind of borderline case, the resize process in total takes about 2 secs, which is acceptable to me.</p>
  
  <p>Now, only one challenge remains. I want the original file to be compressed using that 90% quality but without resizing it. The idea being that that file too will take half the file size. I figured I could simply resize it to its' current dimensions, but that doesn't seem to do anything to the file or its size. Here's my code, somewhat simplified:</p>
  
  <pre><code>$sourceimage = "test.jpg";
  $resize_settings['image_library'] = 'gd2';
  $resize_settings['source_image'] = $sourceimage;
  $resize_settings['maintain_ratio'] = false;
  $resize_settings['quality'] = '90%';
  $this-&gt;load-&gt;library('image_lib', $resize_settings);
  
  $resize_settings['width'] = $imagefile['width'];
  $resize_settings['height'] = $imagefile['height'];
  $resize_settings['new_image'] = $filename;
  $this-&gt;image_lib-&gt;initialize($resize_settings);
  $this-&gt;image_lib-&gt;resize();
  </code></pre>
  
  <p>The above code works fine for all formats except the original. I tried debugging into the CI class to see why nothing happens and I noticed that the script detects that the dimensions did not change. Next, it simply makes a copy of that file without processing it at all. I commented that piece of code to force it to resize but now still nothing happens.</p>
  
  <p>Does anybody know how to compress an image (any image, not just jpegs) to 90% using the CI class without changing the dimensions?</p>