Hi all,

I have been getting ImagickException with imagick on my server but cannot reproduce it on my computer(localhost).

This is when I try to call thumbnailImage(with, height, true) for a JPG

exception 'ImagickException' with message 'Memory allocation failed /tmp/funYYmdPl[0]' @ cache.c/AcquireCacheNexusPixels/416' This is when I call writeImages(path, true) for a GIF exception 'ImagickException' with message 'Memory allocation failed/home/funsub/public_html/uploads/gif/45/45544.gif' @ gif.c/WriteGIFImage/1605'

These are my specs:
ImageMagick 6.5.4-7 2012-05-07 Q16
imagick module version 3.0.1
PHP 5.3.24

I'm on VPS and have set disk usage and bandwidth for that cpanel to unlimited.

I've also tried increasing the php ram usage as well, the problem still occurs.

[root@server ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda3 72G 16G 54G 23% /
tmpfs 427M 0 427M 0% /dev/shm
/dev/vda1 195M 76M 110M 41% /boot
/usr/tmpDSK 622M 50M 541M 9% /tmp

Any ideas why?

Member Avatar for LastMitch

I have been getting ImagickException with imagick on my server but cannot reproduce it on my computer(localhost).

The only thing I can think of is to add a line on the htaccess file and maybe it will read that and you won't get the magickException' with message 'Memory allocation failed.

The line is this

RLimitMem 128000000

You can read more about it here:

http://www.qiq.co.uk/portal/knowledgebase.php?action=displayarticle&id=14

before you load your images in you php-file
ini_set('memory_limit','16M');

Thanks, but it's a memory problem with php, it seems to be imagemagick causing the issue?

Member Avatar for LastMitch

Thanks, but it's a memory problem with php, it seems to be imagemagick causing the issue?

Do you have log file saying imagemagick cause your issue?

Yeah this:

exception 'ImagickException' with message 'Memory allocation failed `/home/funsub/public_html/uploads/gif/46/46621.gif' @ gif.c/WriteGIFImage/1605' in ...

I know that imagick doesn't use PHP memory. To test that out here's what I did.
I set PHP memory limit to 16M on my develpment server, and 256M on production server. I uploaded the same image, ~500MB. Got the error on the production server but not the development server.
I'm considering possibilities like different versions, or RAM limit, or OS differences. Perhaps Imagick is buggy?

Member Avatar for LastMitch

I know that imagick doesn't use PHP memory. To test that out here's what I did.
I set PHP memory limit to 16M on my develpment server, and 256M on production server. I uploaded the same image, ~500MB. Got the error on the production server but not the development server.

OK this is the error you got:

exception 'ImagickException' with message 'Memory allocation failed `/home/funsub/public_html/uploads/gif/46/46621.gif' @ gif.c/WriteGIFImage/1605' in.

I don't know what code you are using.

You can read these 2 links which have a similiar situation as you but is solved differently:

http://ubuntuforums.org/showthread.php?t=884679

https://bugs.php.net/bug.php?id=57995

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.