简体   繁体   中英

Create SVG from image Base64 string, PHP

I have string of image in Base64 in PHP variable. I need to create SVG image which will contain image (image can be PNG/GIF/JPG, whatewer) from that string.

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. 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

<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.

EDIT:

You can add an image inside the svg tag

<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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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