PHP Thumb » Help & Bugs

Memory fatal error

(4 posts)
  1. ykarmi
    Member

    I have the following code:

    $image = PhpThumbFactory::create($image_path);
    $image->adaptiveResize(200, 200);
    $image->save($image_path);

    When I try to resize a JPG with a size of 580KB and dimensions 2560 X 1600, I get the following error:

    Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 10240 bytes)...

    Tried it with a smaller image (both in size and dimensions) and there's no problem. The image is less than 8MB (8388608 bytes) - what's going on and how do I fix it?
    Thanks!

    Posted 2 years ago #
  2. Basically, you need to increase the memory limit in your php.ini file... take a look in there for a directive called "memory_limit".

    The thing with manipulating images is that the amount of memory needed depends on more than just the image size on disk... once all those pixels are loaded in memory things get much larger :)

    Posted 2 years ago #
  3. ykarmi
    Member

    thank you! that solved the problem.

    EDIT: is there a way to catch a memory error?
    something similar to


    try{
    $image = PhpThumbFactory::create($image_path);
    }catch (Exception $e){
    echo "Problem";
    }

    but for the actual resize (this is where it fails).

    this does not work:

    try{
    $image->adaptiveResize(196, 196);
    }catch (Exception $e){
    echo "Problem with resize";
    }

    thanks!

    Posted 2 years ago #
  4. You can't really do much about fatal errors as far as catching them goes unfortunately.

    Posted 2 years ago #

RSS feed for this topic

Reply

You must log in to post.