php-imagine / Imagine

PHP Object Oriented image manipulation library
https://imagine.readthedocs.io
Other
4.42k stars 530 forks source link

Memory limit not throw new RuntimeException #856

Open Triloworld opened 7 months ago

Triloworld commented 7 months ago

This line by default use limited memory: https://github.com/php-imagine/Imagine/blob/922e0327a6b36d1da0acca69993ac85395adcea6/src/Gd/Image.php#L763

What I get:

What we like to get:

This fix temporary to use all machine memory if application setup is less than needed:

        $memory = ini_get('memory_limit');
        ini_set('memory_limit', '-1');
        $resource = imagecreatetruecolor($size->getWidth(), $size->getHeight());
        ini_set('memory_limit', $memory);

There is solution that throw error when memory size isn't enought: https://www.php.net/manual/en/function.imagecreatetruecolor.php#99623