public function replace($zpl, array $params = []) { $variableReplacer = $this->variableReplacer; $zpl = $this->replaceImages($zpl, function ($grf) use($variableReplacer, $params) { $image = $grf->toImage(); $raw = trim(ImageQRCode::decode($image)); $replaced = $variableReplacer->replace($raw, $params); if ($raw !== null && $raw != $replaced && !empty($replaced)) { $imageBox = new ImageBox($image); return GRF::fromImage($imageBox->getReplacedByImage(ImageQRCode::encode($replaced))); } }); return $zpl; }
public function replaceGrf($zpl, $ratio) { return $this->replaceImages($zpl, function ($grf) use($ratio) { /** * @var GRF $grf */ $image = $grf->toImage(); $imageBox = new ImageBox($image); $imageBox->setWidth($imageBox->getWidth() * $ratio); $imageBox->setHeight($imageBox->getHeight() * $ratio); return GRF::fromImage($imageBox->getReplacedByImage($image)); }); }