$uploaddir = " PATH HERE ";
	$convertPath = "/usr/local/nf/bin/";   // full path to ImageMagick's convert tool

$sourcepath = $uploaddir . $randName . '.' . $ext;
$destpath = $uploaddir . 'thumbs/' . $randName . '.thumb.' . $ext;
//	exec("$convertPath $sourcepath -thumbnail x200 -resize 200x< -resize 50% -gravity center -crop 100x100+0+0 +repage -quality 91 $destpath");
        exec("$convertPath $sourcepath -resize 100x100 -quality 87 $destpath");
	exec("$convertPath $sourcepath -resize 640x480 -quality 87 $sourcepath");

This was functioning fine on one server. Then the owner of that sever messed up and we had to move the site to Net Firms. For some reason, this script will create one image, but not the thumbnail. I am trying to figure out why. I did not develop the site and I have little experience. The problem may not be in the code, so any ideas appreciated.

    This most likely has nothing at all to do with PHP, since you're using Imagick as a command line tool rather than a PHP extension. I know nothing about Imagick as a command line tool, but I do know how to see if a command line tool does what it is supposed to. Ssh/telnet/whatever to your server to get to the shell. Try the 3 lines above, i.e.

    	exec("$convertPath $sourcepath -thumbnail x200 -resize 200x< -resize 50% -gravity center -crop 100x100+0+0 +repage -quality 91 $destpath");
            exec("$convertPath $sourcepath -resize 100x100 -quality 87 $destpath");
    	exec("$convertPath $sourcepath -resize 640x480 -quality 87 $sourcepath");
    

    without the exec(); of course. What fails? What works? To see the exact argument sent to exec, use echo

    echo "$convertPath $sourcepath -resize 640x480 -quality 87 $sourcepath";

    If you don't have shell access, you could add a second parameter to the exec function call to capture output.

    There are too many things that can go wrong to take a guess. It could even be that imagick is not installed and the image you thought was created by imagick is actually the image that was uploaded by the user (and moved somewhere by the script).

      Write a Reply...