简体   繁体   English

从图像Base64字符串,PHP创建SVG

[英]Create SVG from image Base64 string, PHP

I have string of image in Base64 in PHP variable. 我在PHP变量的Base64中有图像字符串。 I need to create SVG image which will contain image (image can be PNG/GIF/JPG, whatewer) from that string. 我需要创建SVG图像,该图像将包含该字符串中的图像(图像可以是PNG / GIF / JPG,whatewer)。

Is there any way to do this? 有什么办法吗?

Yes there is a way to this, I will let you create the logic for creating a SVG image. 是的,有一种解决方法,我将让您创建用于创建SVG图像的逻辑。 But here are some usefull links and some basic knowledge: 但是这里有一些有用的链接和一些基本知识:

Check out the w3schools HTML SVG reference: https://www.w3schools.com/graphics/svg_intro.asp 查看w3schools HTML SVG参考: https : //www.w3schools.com/graphics/svg_intro.asp

<svg width="100" height="100">
  <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg>

With these logic you can create your own SVG image, you might want to Google for PHP file writing and reading. 借助这些逻辑,您可以创建自己的SVG图像,您可能希望对Google进行PHP文件的读写。

EDIT: 编辑:

You can add an image inside the svg tag 您可以在svg标签内添加图片

<svg width="5cm" height="4cm" version="1.1"
     xmlns="http://www.w3.org/2000/svg" 
    xmlns:xlink="http://www.w3.org/1999/xlink">
    <image xlink:href="https://www.gettyimages.com/gi- 
       resources/images/CreativeLandingPage/HP_Sept_24_2018/CR3_GettyImages- 
      159018836.jpg" x="0" y="0" height="50px" width="50px"/>
</svg>

https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/SVG_Image_Tag https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/SVG_Image_Tag

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM