I'm trying to save an image using Imagick with php.
When I call saveImage()
or saveImageFile()
I get
Fatal error: Uncaught exception 'ImagickException' with message 'Insufficient memory (case 4)
The image is about 1MB big and the script can use 256MB of memory, which I think should be enough. There is plenty of space available on disk.
What can be the problem?
The code is as follows:
<?php
list($type, $img) = explode(';', $img);
list(, $img) = explode(',', $img);
$data = base64_decode($img);
$image = new Imagick();
$image->readImageBlob($data);
$image->setImageFormat("jpeg");
$image->setInterlaceScheme(Imagick::INTERLACE_PLANE);
$image->writeImageFile(fopen($name.'-original.jpg','w'));
?>
If I try to use file_put_contents()
instead of saveImage()
then an empty file is saved. Perhaps there is a problem with the server configuration?