title: how to use -auto-level +level-colors command argument into PHP ImageMagick
body: <p>I am converting the Image with a specific color and it is working fine with the <code>magick</code> command, below is my command,</p>
  <p><code>magick image.png -channel RGB -colorspace gray -auto-level +level-colors '#f48023',  result.png  </code></p>
  <p>and it is working perfectly fine and now I am converting this command into <code>PHP</code> code but not sure about <code>-auto-level</code> and <code>+level-colors</code> argument. Here is my code,</p>
  <pre><code>$image = new Imagick('image.png');
  $image-&gt;setImageAlphaChannel(Imagick::ALPHACHANNEL_DEACTIVATE);
  $image-&gt;setImageColorspace(Imagick::COLORSPACE_RGB);
  $image-&gt;setImageType(Imagick::IMGTYPE_GRAYSCALE);
  $image-&gt;opaquePaintImage('','#f48023', 0, true);
  $image-&gt;setImageAlphaChannel(Imagick::ALPHACHANNEL_ACTIVATE);
  header(&quot;Content-Type: image/png&quot;);
  echo $image-&gt;getImageBlob();
  </code></pre>
  <p>and the output looks not good at all,</p>
  <p><a href="https://i.stack.imgur.com/Ly7xR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ly7xR.png" alt="enter image description here" /></a></p>
  <p>here is my original Image</p>
  <p><a href="https://i.stack.imgur.com/JqTBN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JqTBN.png" alt="enter image description here" /></a></p>
  <p>**EDIT(Updated code) **</p>
  <pre><code>$im = new Imagick();
  $image = new Imagick('logo3.jpg');
  list ($width, $height) = array_values ($image-&gt;getImageGeometry ());
  $im-&gt;newImage(1, $height,new ImagickPixel('#f48023'));
  $im-&gt;newImage(1, $height,new ImagickPixel('#FFF'));
  $im-&gt;resetIterator();
  $combine  =$im-&gt;appendImages(true);
  
  $image-&gt;setImageAlphaChannel(Imagick::ALPHACHANNEL_DEACTIVATE);
  $image-&gt;setImageColorspace(Imagick::COLORSPACE_GRAY);
  $image-&gt;contrastStretchImage(1,1,Imagick::CHANNEL_GRAY);
  $image-&gt;clutImage($combine);
  $image-&gt;setImageAlphaChannel(Imagick::ALPHACHANNEL_ACTIVATE);
  
  header(&quot;Content-Type: image/png&quot;);
  echo $image;
  </code></pre>
  <p>and output of this code is below</p>
  <p><a href="https://i.stack.imgur.com/7ZIBX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7ZIBX.jpg" alt="enter image description here" /></a></p>
  <p>logo3.jpg is here
  <a href="https://i.stack.imgur.com/TaWHZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TaWHZ.jpg" alt="enter image description here" /></a></p>