脚本宝典收集整理的这篇文章主要介绍了在非常高的图像上使用PHP绘制线条,脚本停止绘制.怎么了,怎么解决?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用imagecreate()遇到了这个问题,然后我发现imagecreatetruecolor()可以处理更大的图像,所以我切换到了.我仍然遇到同样的问题,但脚本现在可以处理更大的图像.我认为它应该绘制大约1200行.该脚本执行时间不超过3秒.这是一张完全执行的图像:http://i.imgur.com/PaXrs.png
我使用ini_set(‘memory_limIT’,’1000M’)调整了内存限制,但我的脚本从未达到接近极限.
如何强制脚本继续绘制直到完成?或者我如何使用PHP来创建使用更少内存的图像(我认为这是问题)?
if(sizeof($array[0])<300) $image=imagecreate($width,$height); else $image=imagecreatetruecolor($width,$height); imagefill($image,imagecolorallocate($image,255,255)); for($p=0; $p<sizeof($linepoints); $p++){ $pOSX1=77+177*$linepoints[$p][0]; $posy1=-4+46*$linepoints[$p][1]; $posx2=77+177*$linepoints[$p][2]; $posy2=-4+46*$linepoints[$p][3]; $image=draw_trail($image,$posx1,$posy1,$posx2,$posy2); } imagepng($image,"images/table_backgrounds/table_background".$tsn.".png",9); imagedestroy($image); function draw_trail($image,$posy2){ $black=imagecolorallocate($image,0); if($posy1==$posy2) imageline($image,$posy2,$black); else{ imageline($image,$posx1+89,$black); imageline($image,$black); } return $image; }
尝试更改代码,以便显式释放您在draw_trail中创建的颜色.此外,由于您传递资源,因此没有理由返回$image.
if(sizeof($array[0])&lt;300) $image=imagecreate($width,255)); for($p=0; $p<sizeof($linepoints); $p++) { $posx1=77+177*$linepoints[$p][0]; $posy1=-4+46*$linepoints[$p][1]; $posx2=77+177*$linepoints[$p][2]; $posy2=-4+46*$linepoints[$p][3]; draw_trail($image,$posy2) { $black=imagecolorallocate($image,0); if($posy1==$posy2) imageline($image,$black); else { imageline($image,$black); imageline($image,$black); } imagecolordeallocate($black); }
以上是脚本宝典为你收集整理的在非常高的图像上使用PHP绘制线条,脚本停止绘制.怎么了,怎么解决?全部内容,希望文章能够帮你解决在非常高的图像上使用PHP绘制线条,脚本停止绘制.怎么了,怎么解决?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。