亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在php中將徽標(徽標是.png格式的圖像)嵌入到另一個圖像(.svg格式的圖像)中

如何在php中將徽標(徽標是.png格式的圖像)嵌入到另一個圖像(.svg格式的圖像)中

PHP
慕桂英3389331 2022-07-22 16:04:22
我想將徽標(.png)集成到另一個圖像(.svg)文件中。我想知道是否可以使用php?我正在使用這個,但這不起作用。<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>我已將 .osm 文件轉換為 .svg,現在當我在 SVG 文件中手動輸入圖像標簽時,我必須在該 .svg 文件中集成一個徽標,該 SVG 文件顯示在 chrome 上但未反映在圖像查看器上。那么有什么方法或文檔嗎?謝謝您的幫助。
查看完整描述

1 回答

?
慕萊塢森

TA貢獻1810條經驗 獲得超4個贊

公共函數 imageEmbed(請求 $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'));

}


查看完整回答
反對 回復 2022-07-22
  • 1 回答
  • 0 關注
  • 111 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號