There may be a problem with the file system. Try to get the file pointer in php first and check for problems
$fileHandle = fopen("path/to/image.jpg", "w");
Then you can use the Imagick function (version 6.3.6 or later);
$im->writeImageFile($filehandle);
Savid
source share