agoat / contao-deferredimages-bundle

Contao 4 deferred images library
GNU Lesser General Public License v3.0
1 stars 0 forks source link

Images not render #8

Closed akroii closed 5 years ago

akroii commented 6 years ago

Hello agoat, I have a gallery with 135 images (á 4000 x 3000 px, > 2MB) which should be rendered. Each image have different image sizes to have a responsive behavior. After I run frontend to initialize image render I got several "500 - internal server error" on many images. Some images will not be rendered. I got an icon that image is broken. Same issue after re-run. I've set my memory_limit very low to simulate normal webhoster, like 1and1, strato eg... If I increase memory_limit to 2G each image will rendered.

Have I misunderstood the intention of the deferredimages?

Versions: php version: 7.1.8 contao: 4.4.8 contao-deferredimages: "agoat/contao-deferredimages": "^1.3"

php.ini:

max_execution_time = 30;
max_input_time = 60; 
memory_limit = 25M; 

PHP Errors during test (short summary):

[02-Apr-2018 10:04:04 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 11224929 bytes) in /Applications/MAMP/htdocs/contao4/vendor/imagine/imagine/lib/Imagine/Gd/Image.php on line 617
[02-Apr-2018 10:04:17 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 7038600 bytes) in /Applications/MAMP/htdocs/contao4/vendor/imagine/imagine/lib/Imagine/Image/Metadata/ExifMetadataReader.php on line 84
[02-Apr-2018 10:04:17 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 7043312 bytes) in /Applications/MAMP/htdocs/contao4/vendor/imagine/imagine/lib/Imagine/Image/Metadata/ExifMetadataReader.php on line 84
[02-Apr-2018 10:04:33 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 8638792 bytes) in /Applications/MAMP/htdocs/contao4/vendor/imagine/imagine/lib/Imagine/Image/Metadata/ExifMetadataReader.php on line 84
[02-Apr-2018 10:04:36 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 7087528 bytes) in /Applications/MAMP/htdocs/contao4/vendor/imagine/imagine/lib/Imagine/Image/Metadata/ExifMetadataReader.php on line 84
[02-Apr-2018 10:04:58 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 7326368 bytes) in /Applications/MAMP/htdocs/contao4/vendor/imagine/imagine/lib/Imagine/Image/Metadata/ExifMetadataReader.php on line 84
[02-Apr-2018 10:05:03 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 3393900 bytes) in /Applications/MAMP/htdocs/contao4/vendor/imagine/imagine/lib/Imagine/Image/Metadata/ExifMetadataReader.php on line 84
[02-Apr-2018 10:05:39 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 7758280 bytes) in /Applications/MAMP/htdocs/contao4/vendor/imagine/imagine/lib/Imagine/Image/Metadata/ExifMetadataReader.php on line 84
[02-Apr-2018 10:06:00 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 3191920 bytes) in /Applications/MAMP/htdocs/contao4/vendor/imagine/imagine/lib/Imagine/Image/Metadata/ExifMetadataReader.php on line 84
[02-Apr-2018 10:06:00 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 32768 bytes) in /Applications/MAMP/htdocs/contao4/vendor/patchwork/utf8/src/Patchwork/Utf8.php on line 681
[02-Apr-2018 10:06:24 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 9921028 bytes) in /Applications/MAMP/htdocs/contao4/vendor/imagine/imagine/lib/Imagine/Image/Metadata/ExifMetadataReader.php on line 84
[02-Apr-2018 10:06:33 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 3861592 bytes) in /Applications/MAMP/htdocs/contao4/vendor/imagine/imagine/lib/Imagine/Image/Metadata/ExifMetadataReader.php on line 84
[02-Apr-2018 10:06:33 Europe/Berlin] PHP Fatal error:  Allowed memory size of 26214400 bytes exhausted (tried to allocate 32768 bytes) in /Applications/MAMP/htdocs/contao4/vendor/patchwork/utf8/src/Patchwork/Utf8.php on line 681
agoat commented 6 years ago

The main intention is to avoid timeouts during page generation. The amount of memory used is nearly the same as when the images are resized directly.

memory_limit = 25M;

I think it's not possible to resize an image with that low memory limit. I made a quick test with images that have dimensions around 4000x3000px and the script uses around 50-60MB. And the PHP Errors of your logfile are telling that the memory limit is exhausted by the imagine/imagine library which is used for image calculations.

The source image itself must fit into the memory. An RGB image with 4000x3000px will have an uncompressed size of 34MB (4000px 3000px 24bit / 8bit / 1024 / 1024).

You will need to set the memory_limit to 64MB or you can only use images with dimensions up to 2000x2000px.