This repository was archived by the owner on Dec 9, 2023. It is now read-only.
Output buffering may truncate image output#127
Open
rk wants to merge 1 commit intoIntervention:masterfrom
Open
Output buffering may truncate image output#127rk wants to merge 1 commit intoIntervention:masterfrom
rk wants to merge 1 commit intoIntervention:masterfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 correctob_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.