PHP渲染图像文件

Lan*_*fee 1 php apache image

在渲染图像文件时,我有哪些选择?假设我在foo/bar.png中保存了一个

目前我知道我可以使用readfile()或更好,X-Sendfile(我在Apache上).有什么其他方法比使用更好readfile()

我想将图像输出到浏览器(Content-Type:image/png)

Fra*_*til 5

最好的解决办法是让你的网络服务器(Apache)的服务内容本身.如果必须使用PHP,那么您需要确保首先将Content-Type设置为适当的值:

header("Content-type: image/png");
Run Code Online (Sandbox Code Playgroud)

然后readfile()用来发送图像本身.