encode base64 svg file to path d attribute - svg

I have svg file base64 code, example, data:image/svg+xml;base64,PHN2ZyBpZD0iQ2FwYV8...
I want to convert this svg file using path method, example, <path d="114.939 0H10.449C4.678 .."
There is any converter or trick how can I do that?
Please help.

If someone is wondering I found answer to my own question.
Source link is https://www.sitepoint.com/community/t/converting-an-svg-path-to-a-base64-data-uri-string/278874/7
Easiest solution:
copy base64 string
paste string into browser address bar
browser will generate svg file
check browser source and you will see path d=".." information.

Related

How to convert an asciidoc with cyrillic symbols to pdf?

I have created an .adoc file and want to convert it to PDF.
I am using Linux Debian and GEdit for writing the .adoc. I followed all the steps to install asciidoc-pdf, RVM, etc. from here. And it actually works, but for some reason it doesnt want to convert my file.
I downloaded a readme for Asciidoctor PDf converter and tried to convert it to pdf to see if all is working correctly and it converted with no problem.
When I try to convert my file, it only converts the title and that's it. When I try to convert it to HTML, I get a bit more - the line with the name of the author (my name). And I can't understand what's wrong.
I even tried to write the same file from scratch with no result.
Here is a sample of my file:
= Как купить билет на сайте РЖД
Маркиев Владимир <grolribasi#gmail.com>
:hide-uri-scheme:
:imagesdir: img
ifdef::env-github[]
:importatnt-caption: :warning:
:source-highlighter: rouge
Инструкция:: Данная инструкция поможет вам приобрести билет най сайте hhtps://rzd.ru
. Наберите в адресной строке браузера rzd.ru, откроется главная страница сайта.
+
--
image::1.png[главная страница]
--
After some reading, I found out that this is due to Cyrillic symbols in my document. I found out that now Asciidoc supports Cyrillic symbols in documents, but you need to specify font family as "Noto Serif" in the header:
base-font-family: Noto Serif
I tried to set the font family, added the line, but it still doesn't want to convert to pdf.
I guess, now the main question is: how to use Cyrillic symbols in asciidoc.
This ifdef
ifdef::env-github[]
is never closed.
Try to close it that way:
ifdef::env-github[]
:importatnt-caption: :warning:
:source-highlighter: rouge
endif::env-github[]

Can I import svg into Gideros?

Ok I will admit to being a noob with Gideros. I am trying to import an svg file. I followed the same procedure as you would do for a png file, that is create a texture using:
myTexture = Texture.new("orangeSquare.svg")
orangeSquare = Bitmap.new(myTexture)
stage:addChild(orangeSquare)
Unsurprisingly it doesn't work (output gives orangeSquare.svg: Error while reading image file. and program does not run) as it is not a bitmap file. Is there an alternative to import svg files? It is probably a very simple solution but I have been searching for some time without an answer. I am considering giving up on Gideros if I don't find an answer to what should be a simple problem.
You can not import the svg directly, you need to pass the svg data:
--Banana shape, SVG path format
local banana = "M8.64,223.948c0,0,143.468,3.431,185.777-181.808c2.673-11.702-1.23-20.154,1.316-33.146h16.287c0,0-3.14,17.248,1.095,30.848c21.392,68.692-4.179,242.343-204.227,196.59L8.64,223.948z"
p=Path2D.new()
p:setSvgPath(banana) --Set the path from a SVG path description
p:setLineThickness(5) -- Outline width
p:setFillColor(0xFFFF80,0.7) --Fill color
p:setLineColor(0x404000) --Line color
p:setAnchorPosition(100,100)
stage:addChild(p)
You can find more info on their wiki: https://wiki.giderosmobile.com/index.php?search=svg&title=Special%3ASearch&go=Go&fulltext=1
They also have it as a sample project when you open gideros studio.

Image to binary string

I need this for a scriptUI panel I am working on. I am trying to add a custom image button and the image to be part of the jsx file.
Does somebody know how this kind binary string is achieved, and how do I turn a png file to string of that type '\u0089PNG....' (is it initially Base64 encoded and then another encoding, or is it an encoded Byte array):
http://i.imgur.com/n2wpdmQ.png
Thanks in advance!
I found the solution using ExtendScript Toolkit
var img = File("1.png");
img.open('r');
img.encoding = 'BINARY';
var imgstr = img.read();
img.close();
$.writeln(imgstr.toSource());
It reads the PNG image and outputs the string in the console.
Thanks!

decode base64 svg data to a svg file

I have a file containing a svg image which is base64 encoded (data-uri). The file starts with
data:image/svg+xml;base64,PHN....
How to decode this to a .svg file in linux ?
You can copy/paste the string (data:imageetc included) in the url bar of a modern browser; it will decrypt it for you, then you can simply save the page as an svg.
You could use an online base64 decoder, such as http://www.base64decode.org/
To address the OP question:
How to decode this to a .svg file in linux ?
Since linux has python by default, I suggest to use python script.
Here is a working example:
import base64
#change "YOURFILE" with the name of your original file
with open("YOURFILE", "rb") as f: encoded = f.read()
encoded = encoded.replace("data:image/svg+xml;base64,", "")
decoded = base64.b64decode(encoded)
#change "NEWFILE" with the name that you want to give your new svg
with open("NEWFILE.svg", "wb") as f: f.write(decoded)
If you are new to python, simply copy-paste the code above into a file with .py extension, for example aaabbb.py and then execute it like this:
python aaabbb.py
You can use e.g base64 --decode < "your base64 data here". And you probably need to strip off the data:image/svg+xml;base64, part before passing it in.
or you can use the online tool
http://www.hosting4free.info/Base64Decode/Base64-Decode.jsp
I use SVG online decoder, fast and simple
https://base64.online/decoders/decode-base64-to-svg
I resolved problem:
let base64 = 'data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMM...'
let url = base64.replace("data:image/svg+xml;base64,", "");
var svg = decodeURIComponent(escape(window.atob(url)));

Highcharts PhantomJS export SVG as base64

I have a question regarding generating an SVG instead of an PNG serverside using PhantomJS. I have PhantomJS running as a server and am POSTing JSON to it (http://www.highcharts.com/docs/export-module/render-charts-serverside). I would like to receive an SVG represented as a BASE64 result stream. I am running in some problems however.
I tried both the following requests, but the base64 result would always represent a png file:
{"infile":".......", "type":"image/svg+xml"}
And:
{"infile":".......", "type":"svg"}
I do however get a valid svg file when I use the outfile parameter:
{"infile":".......", "type":"svg", "outfile":"anActualSVG.svg"}
This writes a file to disk, which is not what I am looking for.
Does anyone have some suggestions?
Thanks!

Resources