使用PHP将图像旋转45度时如何避免黑色背景?
您好,我必须先翻转缩略图,然后才能将其与另一个 jpeg 文件合并。但是当我使用 php.ini 旋转 45 度时它显示黑色背景。我怎样才能避免这种情况。任何机构都可以帮助我。
Hi I have to flip a thumpnail image before merge it with another jpeg file. but when I rotate 45 degree using php. It shows a black background. how can I avoid that. any body can help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,如果您要生成 jpg,请使用 PHP GD 将背景颜色设置为函数
imagerotate
的第三个选项。在此示例中,我假设您将 jpg 图像$filename
旋转任意$angle
度,并且您想要白色背景,即颜色代码16777215
:黑色是颜色代码
0
,这是默认值,其余的颜色伽玛介于两者之间,因此您只需决定要编辑的 背景颜色:
对于透明背景,如果您要生成 png,您会这样做:
希望有帮助
Well, if you are generating a jpg, using PHP GD you set the color of the background as the third option of the function
imagerotate
. In this example I'm gonna assume that you are rotating a jpg image$filename
by an arbitrary$angle
degrees, and you want a white background, i.e. color code16777215
:black is color code
0
, which is default, and the rest of the color gamma is in between the two, so you just need to decide which background color you would likeEDIT:
for transparent backgrounds, if you are generating a png you would do:
Hope that helps
另外,您的水印图像有 Alpha 通道还是完全不透明?
Also, do your watermark images have alpha channel or are they fully opaque?