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.
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.
/opt/local/bin/convert /Users/flash_tekkie/developer_tools/ImageMagick_test.png -debug 'All' -units PixelsPerInch -density 320 /Users/flash_tekkie/developer_tools/ImageMagick_test_320.png
In the circumstances ImageMagick returned 5, which produced a following log entry:
21.10.11 16:57:41 com.apple.ReportCrash.Root 2011-10-21 16:57:41.603 ReportCrash[9037:2617] Saved crash report for convert version ??? (???) to /Library/Logs/DiagnosticReports/convert_2011-10-21-165741-5_localhost.crash
and within the crash file:
Process: convert  Path: /opt/local/bin/convert Identifier: convert Version: ??? (???) Code Type: X86 (Native) Parent Process: httpd  Date/Time: 2011-10-21 17:00:53.674 +0200 OS Version: Mac OS X 10.6.8 (10K549) Report Version: 6 Exception Type: EXC_BREAKPOINT (SIGTRAP) 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.