Memory limit when uploading product image

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:

Find:

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.


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