I just setup a testing installation yesterday. I ran the server-check file and all was fine. Installation went smoothly.

The image upload doesn't work in the Backend! After uploading any image, even as small as 1kb, the error "Memory limit has been reached." appears and the image is not stored. The memory limit for PHP is set very high (several GiB or even -1 for unlimited)

  • 2
    the question is pretty clear... these mod's on this site are power tripping – acctman Sep 30 '14 at 18:41
  • 4
    I have the same problem and a solution! Since the power tripping mods closed it I can't answer! Here is a short summary: In the file /lib/Varien/Image/Adapter/Gd2.phpis the function ` _convertToByte` that doesn't know about GB or -1! add: elseif (stripos($memoryValue, 'G') !== false) { return (int)$memoryValue * 1024 * 1024 * 1024; } elseif (trim($memoryValue) == '-1') { return 8589934592; } – Josef Nov 19 '14 at 14:05
  • hi josef......... – Teja Bhagavan Kollepara Dec 23 '15 at 7:40
  • 1
    @Josef. It was helped me , And thank you. – Teja Bhagavan Kollepara Dec 23 '15 at 7:45

You can try to increase de memory limit of your php:

Open /etc/php5/apache2/php.ini in a text editor

Change memory_limit to:

memory_limit = 256M

And you can check creating a file info.php

<?php phpinfo(); ?>

Check the variable: memory limit

  • Thanks! I actually had the memory_limit set to -1 for unlimited so I didn't think that was the problem. Reset it back to an actual limit and it's working fine. – Tracy Aug 3 '14 at 20:17

There is a known bug in the GD library of Magento CE 1.x where it can't handle memory limits other than in KB or MB. To solve the issue and assign higher memory limits (GB), you will need to make the following changes to the file /lib/Varien/Image/Adapter/Gd2.php:


protected function _convertToByte($memoryValue)
    if (stripos($memoryValue, 'M') !== false) {
        return (int)$memoryValue * 1024 * 1024;
    elseif (stripos($memoryValue, 'KB') !== false) {
        return (int)$memoryValue * 1024;

    return (int)$memoryValue;

Add the following lines before the final return statement:

    elseif (stripos($memoryValue, 'G') !== false) {    // Support value in gigabytes
        return (int)$memoryValue * 1024 * 1024 * 1024;
    elseif (trim($memoryValue) == '-1') {              // Support unlimited memory
        return 8589934592;                             // Use 8GB

Thanks to Sangay Tenzin and @Josef for making this info available.

  • 1
    Probably easier to just convert G to M, but nice to know about the BUG! – Tim Ramsey Nov 28 '18 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.