I want to integrate a logo (.png) in a another image(.svg) file. I would like to know is it possible using php?
I am using this , but this is not working .
<image x="0" y="0" width="10" height="10" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://bellard.org/bpg/2.png" onclick="this.setAttributeNS('http://www.w3.org/1999/xlink', 'href', 'http://pngimg.com/uploads/polar_bear/polar_bear_PNG23514.png')">
</image>
I have converted a .osm file into .svg and now I have to integrate a logo inside that .svg file when I enter an image tag manually inside that SVG file that is showing on chrome but not reflected on image viewer. So is there any way or documentation for this?
Thank you for your help.
public function imageEmmbed(Request $request){
$file = $request->file('file');
$svg_data = file_get_contents($file);
$svg = new \SimpleXMLElement($svg_data, LIBXML_NOEMPTYTAG);
$svg->registerXPathNamespace('svg', 'http://www.w3.org/2000/svg');
$g_res= $svg->addChild("text", "COPYRIGHT @ 2020");
$g_res->addAttribute("x", "150");
$g_res->addAttribute("y", "220");
$g_res->addAttribute("font-family", "Verdana");
$g_res->addAttribute("font-size", "10");
$g_res->addAttribute("fill", "red");
$g_res = $svg->addChild("image","1");
$g_res->addAttribute("x", "0");
$g_res->addAttribute("y", "0");
$g_res->addAttribute("width", "50");
$g_res->addAttribute("height", "50");
$g_res->addAttribute("xlink", 'http://www.w3.org/1999/xlink');
$g_res['xlink:href'] = "enter your base64 image here.";
$g_res->addAttribute("onclick", "this.setAttributeNS('http://www.w3.org/1999/xlink')");
$dom_res = dom_import_simplexml($g_res);
$dom_svg = dom_import_simplexml($svg);
$dom_svg->formatOutput = true;
$dom_svg->appendChild($dom_res);
echo $svg->saveXML(public_path('image/test.svg'));
}