title: php imagick JPEG2000 compression increases in filesize
body: <p>I am using imagick php extension to create <strong>.webp</strong> and <strong>.jp2</strong> files from .jpg and compress the image during the process. I'm getting good results for .webp images, but having some issues with .jp2.</p>
  <p>This is my code to create <strong>webp</strong>:</p>
  <pre><code>&lt;?php
  $img = new Imagick(&quot;test.jpg&quot;);
  $img-&gt;setImageFormat(&quot;webp&quot;);
  $img-&gt;setImageCompression(Imagick::COMPRESSION_JPEG);
  $img-&gt;setImageCompressionQuality(50);
  $img-&gt;writeImage(&quot;test.webp&quot;);
  ?&gt;
  </code></pre>
  <p>And this works fine, my webp is almost 90% decreased in file size compared to jpg. But using the same technique for JPEG2000 (jp2), I have an increase in file size of around 30%.</p>
  <p>This is the code I'm using for <strong>jp2</strong>:</p>
  <pre><code>&lt;?php
  $img = new Imagick(&quot;test.jpg&quot;);
  $img-&gt;setImageFormat(&quot;jp2&quot;);
  $img-&gt;setImageCompression(Imagick::COMPRESSION_JPEG2000);
  $img-&gt;setImageCompressionQuality(50);
  $img-&gt;writeImage(&quot;test.jp2&quot;);
  ?&gt;
  </code></pre>
  <p>I tried many different images as a sourcefile (compressed and uncompressed), all had the same result. Any insights to what I am doing wrong? Thanks.</p>