blog’s amazing Rotating Header Image

PHP memory_limit calculator for image resizing

Do you have some image resizing PHP code out in the wild? You’d better prepare yourself: your code may break anytime if you don’t pay attention to the memory limit settings of PHP. (God, it could already did!)

Take care of the plenty megapixel images and avoid trouble now!

How many memory do you really need? Find it out for yourself! The labs proudly presents the hot’n’sexy PHP memory limit calculator for image resizing! Check it and process images like a pro.

Should you have any questions regarding image resizing and memory allocation, feel free to ask in the comments!

Bookmark and Share


  1. Daks says:

    How about if I need to resize a large image 3 times? Do I need to add all their memory limits?


    ini_set( ‘memory_limit’, $newLimit . ‘M’ );

    $img = new resize($file);

    $img -> resizeImage(60, 60, ‘crop’);;
    $img -> resizeImage(250, 125, ‘pad’);
    $img -> resizeImage(540, 380, ‘pad’);

    So I could save all 3 sizes in the database. Thanks for the calculator, appreciate it.

  2. d-a-m says:

    It absolutely depends on how you’re organizing the images into variables. You’ll definitely need the memory footprint for the largest image source and its destination variable.

    The safe way is to reserve enough space for the rest of the images too. However, you can unset() the unused image variables to free up memory, which helps optimizing memory (technically unset()ed variables will still occupy memory until the garbage collection occurs, but when PHP is getting low on memory, it will execute the garbage collection routines as needed).

Leave a Reply