If you’ve installed ImageMagick from MacPorts, e.g. for a 32-bit Mac for which there are no prebuilt binaries, you could have seen ImageMagick not working with PHP exec() on localhost even though it works from  the command line.

A successful exec("convert...") call  should always return 0. If not, there’s an error. Whenever the result is unexpected, it’s a good idea to add a flag of -debug 'All' to the ImageMagick command, e.g. 

-debug 'All' -units PixelsPerInch -density 320 

In the circumstances ImageMagick returned 5, which produced a following log entry:

21.10.11 16:57:41 com.apple.ReportCrash.Root[9037] 
2011-10-21 16:57:41.603 ReportCrash[9037:2617] 
Saved crash report for convert[9043] version ??? (???) to 

and within the crash file:

Process:         convert [9152]
Path:            /opt/local/bin/convert
Identifier:      convert
Version:         ??? (???)
Code Type:       X86 (Native)
Parent Process:  httpd [2655]
Date/Time:       2011-10-21 17:00:53.674 +0200
OS Version:      Mac OS X 10.6.8 (10K549)
Report Version:  6
Exception Codes: 0x0000000000000002, 0x0000000000000000
Crashed Thread:  0
Dyld Error Message:
  Library not loaded: /opt/local/lib/libfreetype.6.dylib
  Referenced from: /opt/local/bin/convert
  Reason: Incompatible library version: convert requires version 14.0.0 or later, but libfreetype.6.dylib provides version 13.0.0
Binary Images:
0x8fe00000 - 0x8fe4162b  dyld 132.1 (???) <A4F6ADCC-6448-37B4-ED6C-ABB2CD06F448> /usr/lib/dyld

To resolve the above conflict of libraries, recompiling with MacPorts didn’t help. The conflict lied in the library of the server instance, in the circumstances MAMP which had to be replaced. XAMPP worked out perfectly.