title: Php exec command to convert an image
body: <p>I'm trying to use the imagemagick command "convert" to create a .tif image from a .png one.</p>
  
  <p>What I've come with is:</p>
  
  <pre><code>$exec = "/opt/local/bin/convert -adaptive-resize 150% ".$pos.".png ".$pos.".tif";
  exec($exec);
  </code></pre>
  
  <p>If I run into CLI "which convert" I get that path: <code>/opt/local/bin/convert</code> . I've also tried without the path, only <code>/opt/local/bin/convert -adaptive-resize 150% ".$pos.".png ".$pos.".tif</code> and <code>/etc/local/bin/convert -adaptive-resize 150% ".$pos.".png ".$pos.".tif</code>.</p>
  
  <p>If I'm running that command into the terminal it works as expected but when I'm trying to use it from the PHP script it doesn't work.</p>
  
  <p>EDIT:
  I've also tried without success to create a .sh file with the following code:</p>
  
  <pre><code>#! /bin/bash
  convert -adaptive-resize 150% 1.png 1.tif
  convert -adaptive-resize 150% 2.png 2.tif
  convert -adaptive-resize 150% 3.png 3.tif
  convert -adaptive-resize 150% 4.png 4.tif
  convert -adaptive-resize 150% 5.png 5.tif
  convert -adaptive-resize 150% 6.png 6.tif
  convert -adaptive-resize 150% 7.png 7.tif
  convert -adaptive-resize 150% 8.png 8.tif
  convert -adaptive-resize 150% 9.png 9.tif
  </code></pre>
  
  <p>If I run it from terminal it works like a charm.
  Instead if I try to execute it from a simple PHP file it doesn't create any .tif file.</p>
  
  <pre><code>&lt;?php
  $exec = "./convertpngtif.sh";
  exec($exec);
  ?&gt;
  </code></pre>