how to avoid "out of memory" error when i create a thumbnail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lukelee
Forum Commoner
Posts: 28
Joined: Wed Sep 10, 2008 2:03 am

how to avoid "out of memory" error when i create a thumbnail

Post by lukelee »

Hi, guys, i am making a cms to allow people upload 5 images at once, the problem is when the total size>1.3mb, "fetal error- out of memory" occurs. is there any way to avoid it? my memory limit is 64 and i cant change this number.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: how to avoid "out of memory" error when i create a thumbnail

Post by requinix »

Ha ha, "fetal" error.

First, are you using imagedestroy when you finish thumbnailing? That frees up memory.

If that doesn't help and you can't increase the memory limit then you have two choices:
1) Use something else to make thumbnails (like ImageMagick)
2) Impose a limit on the size of images
lukelee
Forum Commoner
Posts: 28
Joined: Wed Sep 10, 2008 2:03 am

Re: how to avoid "out of memory" error when i create a thumbnail

Post by lukelee »

seems thats a common problem.
whats the imagedestroy? and how to use it? is it a code?
and i have heared about imagemagick, but dont know how to use it.

I would like to try both way, can you provide me some samples?
thanks.
Post Reply