为$ bgd_color传递-1时php gd imagerotate失败 [英] php gd imagerotate fails when -1 is passed for $bgd_color

查看:58
本文介绍了为$ bgd_color传递-1时php gd imagerotate失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在客户端服务器上遇到了这个问题

I had this problem on a client server

$tmp = imagerotate($tmp, $angle, -1);

$ tmp => bool(false),不显示错误消息

$tmp => bool(false) with no error message displayed

$tmp = imagerotate($tmp, $angle, imagecolorallocatealpha($tmp, 0, 0, 0 , 127));

这很好用
$ tmp =>类型(gd)的 resource(89)

应该更改哪个服务器配置变量以使-1工作?

What server configuration variable should be changed to make -1 work ?

GD Version: bundled (2.1.0 compatible)
libPNG Version: 1.2.44

推荐答案

应该更改哪些服务器配置变量以使-1正常工作?"

"What server configuration variable should be changed to make -1 work?"

没有服务器配置变量可以使此工作正常进行.我遇到了与您相同的问题(使用第三方库时),发现传递-1的人非常幸运,它确实起作用了.根据我的研究,我相信发生了什么事,一个人使用了它,它起作用了,并且代码只是复制到了各个项目中而没有真正了解它的功能.我之所以这样说,是因为我在各个项目中看到的是完全相同的代码,包括注释.

There is no server configuration variable that makes this work. I ran in to the same issue as you (while using a third party library) and discovered that those who were passing in -1 were pretty much lucky that it did work. Based on my research I believe what happened was one person used this, it worked, and the code just got copied into various projects without a real understanding of it's function. I say this because I see the same exact code, including comments, in various projects.

gd库的更高版本改变了某些行为,打破了将-1作为背景色传递给那些人的 imagerotate 函数.

Later versions of the gd library changed the behavior some, breaking the imagerotate function for those who were passing in -1 as the background color.

无论如何,解决方案是使用 imagecolorallocatealpha 向图像调色板添加透明的颜色",并将该颜色作为背景色传递给 imagerotate .您的解决方案: $ tmp = imagerotate($ tmp,$ angle,imagecolorallocatealpha($ tmp,0,0,0,127)); 应该很好.

Anyway, the solution is to use imagecolorallocatealpha to add a transparent "color" to the image palette, and pass that color as the background color to imagerotate. Your solution of: $tmp = imagerotate($tmp, $angle, imagecolorallocatealpha($tmp, 0, 0, 0 , 127)); should be just fine.

这篇关于为$ bgd_color传递-1时php gd imagerotate失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆