title: PHP: changing DPI of an image using imagick?
body: <p>I'm trying to figure out how to increase an image DPI using PHP and imagic.</p>
  
  <p>However, everytime I use the following code, my page returns a 500 error!</p>
  
  <p>this is the code:</p>
  
  <pre><code>$im = new Imagick();
  $im-&gt;setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
  $im-&gt;setImageResolution(300,300);
  $im-&gt;readImage("test.png");
  $im-&gt;setImageFormat("png");
  header("Content-Type: image/png");
  echo $im;
  </code></pre>
  
  <p>I know image magic is installed as I am using a VPS and I also tried this code which works fine:</p>
  
  <pre><code>&lt;?php
  exec("/usr/bin/convert bb9yuui70.png -bordercolor black -border 10x10 bb9yuui70.png");
  ?&gt;
  &lt;img src="bb9yuui70.png"&gt;
  </code></pre>
  
  <p>Is there something that i am missing? I am quite new to the world of imagic.</p>
  
  <p>any help would be appreciated.</p>