Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Output buffering may truncate image output #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rk
Copy link

@rk rk commented Jun 21, 2022

In some server configurations, output buffering will cause the image content to be truncated by approximately 5 rows of pixels. I confirmed that this happened with both PHP 7.4 and 8.0, using both GD and Imagick drivers.

To verify, I recreated the original issue by using ob_start() on the same line in my local MAMP environment. Output was then truncated, and my browser showed an image corrupt message. Swapping it for the correct ob_end_clean() resolved the issue on both my development and the production machines.

This just ensures that any automatic output buffering is turned off properly.

In some server configurations, output buffering will cause the image content to be truncated by approximately 5 rows of pixels. I can confirm that this happened with both PHP 7.4 and 8.0, using both GD and Imagick drivers. I was able to recreate the original issue by using `ob_start()` on the affected line using my local MAMP environment. Switching it to `ob_end_clean()` resolve the issue on both my development and the production machines.

The solution is to just end output buffering before processing the response.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant