在用户栏上有一个Add filters to Interactive Grid via Javascript用于呈现数据。
它工作正常,但我想澄清一下。在此过程中,数据会叠加在图像上,并且clone
和Imagick
都应使用ImagickDraw
-保存以前的叠加层。
private function createImage($file): Imagick
{
$this->Imagick = new Imagick(__DIR__.'/Draw/Images/'.$file);
return $this->Imagick;
}
如何使用clone
的示例:
private function drawRank(): Imagick
{
$image = clone $this->Imagick;
$rank = $this->createImage(self::RANK_IMAGE);
$rank->cropImage(32,32,$this->vector[$this->interface->rank_id]);
$image->compositeImage($rank,Imagick::COMPOSITE_DEFAULT,64,18);
return $image;
}
最后结果是这样的:
private function call()
{
$this->Imagick = $this->createImage(self::BACKGROUND_IMAGE[$this->l]);
$this->Imagick = $this->drawRank();
$this->Imagick = $this->drawingProfile();
header('Content-Type: image/'.$this->Imagick->getImageFormat());
echo $this->Imagick;
}
这有多正确?我对此方法表示怀疑。这是正常的做法吗?