Page 1 of 1

Memory Allocation Error

Posted: 2012-08-21T09:35:20-07:00
by webdevsoup
Hey everyone, question for those of you out there that are geniuses (I'm a newbie to IM). I am running ImageMagick-6.5.4.7-5.el6.x86_64 and CentOS 6.0 Final. When running a script to create thumbnails, I am getting the following errors:

Code: Select all

exception 'ImagickException' with message 'Memory allocation failed `/tmp/magick-XXIaQCm8' @ psd.c/ReadPSDImage/1035' in /home/opmadb/html/metaprocess/testrender.php:57
Stack trace:
#0 /home/opmadb/html/metaprocess/testrender.php(57): Imagick->__construct('/home/opmasan/m...')
#1 {main}
testrender.php:57-66 is as follows:

Code: Select all

$thumb=new Imagick($local_path);
			$thumb->flattenImages();
			$thumb->setImageColorspace(Imagick::COLORSPACE_SRGB);
			//Scale the image
			$thumb->thumbnailImage(128,128,true,false);
			$thumb->setImageFormat("png");
			$thumb->stripImage();
			
			//Write the new image to a file
			$thumb->writeImage('/home/metathumbs/'.$image_data->thumb);
When I look in to the error a little bit more, line 1035 in ImageMagick is something to do with the layers in the photo.

Examples can be gotten here (File size is 46MB compressed):

http://www.sfwdesign.com/sites/all/imag ... pd.psd.zip

Thanks for any help.

Re: Memory Allocation Error

Posted: 2012-08-21T09:46:00-07:00
by magick
Perhaps you need to increase the maximum amount of memory a script may consume for PHP. The default may be as low as 8MB. In our php.ini script file, we use
  • memory_limit = 128M
If you cannot increase the limit, set your memory resource limit to say 2MiB (not sure how this is done in IMagick, from the command line its -limit memory 2MiB). If an image or a set of images exceed this limit, all subsequent images are cached to disk to reduce the memory resource consumption.

Re: Memory Allocation Error

Posted: 2012-08-21T09:49:38-07:00
by webdevsoup
magick wrote:Perhaps you need to increase the maximum amount of memory a script may consume for PHP. The default may be as low as 8MB. In our php.ini script file, we use
  • memory_limit = 128M
If you cannot increase the limit, set your memory resource limit to say 2MiB (not sure how this is done in IMagick, from the command line its -limit memory 2MiB). If an image or a set of images exceed this limit, all subsequent images are cached to disk to reduce the memory resource consumption.
I have already done this. My memory is at, I believe, 256M. The issue is not with the size, because I have larger images that process fine, for instance 84MB that process through normally, with no errors.

Re: Memory Allocation Error

Posted: 2013-12-03T10:30:04-07:00
by slange
Hello,
i have the same problem using ImageMagick 6.5.4-7 2012-05-07 Q16 OpenMP.

Code: Select all

2013-12-03T18:22:37+01:00 0:01 3.490u 6.5.4 Coder identify[19382]: psd.c/ReadPSDImage/1032/Coder
    allocation of image for layer 4 failed
2013-12-03T18:22:37+01:00 0:01 3.490u 6.5.4 Exception identify[19382]: psd.c/ReadPSDImage/1035/Exception
  Memory allocation failed test.psd

Code: Select all

identify -verbose -debug all "./test.psd"[5]
Is there any solution so far?

Regards