title: Transparent to white in Imagick for PHP
body: <p>I have a png image with a transparent background and I want to convert it to a jpg image with a white background.</p>
  
  <p>The code is basically this:</p>
  
  <pre><code>$image = new Imagick('transparent.png');
  $image-&gt;writeImage('opaque.jpg');
  </code></pre>
  
  <p>But that creates a black background jpg. I've been struggling with the worst documentation ever trying to find a way to convert the transparent to white to no avail.</p>
  
  <p><strong>Edit</strong>:
  Well, I tried Marc B's idea and kind of got it to work.</p>
  
  <pre><code>$image = new Imagick('transparent.png');
  $white = new Imagick();
  
  $white-&gt;newImage($image-&gt;getImageWidth(), $image-&gt;getImageHeight(), "white");
  $white-&gt;compositeimage($image, Imagick::COMPOSITE_OVER, 0, 0);
  $white-&gt;writeImage('opaque.jpg');
  
  $image-&gt;destroy();
  $white-&gt;destroy();
  </code></pre>
  
  <p>The problem now is, it always causes the script to segfault.</p>