dongtuo1482 2016-11-30 11:03
浏览 96

如何在PHP中一次在多个图像中绘制填充矩形?

I need to draw color filled rectangles in multiple images at the same time.

$path      = "D:\Images\sample.png";      
$result_path  = "D:\Images\output\sample_output.png";
$image        = imagecreatetruecolor(500, 700);
$image        = imagecreatefrompng($path);
$color        = imagecolorallocatealpha($image, 181, 255, 1, 75);
imagefilledrectangle($image, 15, 15, 30, 30, $color);
header('Content-Type: image/png');
imagepng($image, $result_path);
imagedestroy($image);

This code helped to draw a filled rectangle in a single image.

Is it possible to draw filled rectangles on multiple images at the given co-ordinates of x and y?

  • 写回答

1条回答 默认 最新

  • duancanjiu3754 2016-11-30 11:09
    关注

    To draw multiple images in PHP from different requests at the same time you can't save the image to a static filename. $result_path should be NULL or your call to imagepng shouldn't include a second argument. It can be reduced to imagepng($image). The code you have posted will output the png to a file but it won't display the image.

    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效