In message <v7p2ia$1bf9s$
[email protected]>
druck <
[email protected]> wrote:
On 22/07/2024 21:25, Alexander Ausserstorfer wrote:
I want to save and convert this BASE64 block to a data file. My idea is to >> use !Attacher to do the job.
Python has a base64 module and you can pass any length string to it's
decode function. I haven't checked if it's available on RISC OS though.
---druck
Yes,
To test Python code (works with Python3 on RISC OS)
import base64, binascii
# to replace with your string.
base64_string = "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tI FVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvI
E1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iM
CAwIDUxMiA1MTIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbD0iI
zAwMDAwMCIgZD0iTTQ1OC45MTUgMzA3LjcwNWMwIDYyLjYzLTU0IDkxLjMyLTkxLjM0IDkxLjM0LTQxL
jY0IDAtNzMuMS0xOC44Ni05MS44My0zNC4yNiAyLjQ3IDUwLjk1IDE0LjUzIDg3LjM1IDY4LjY1IDExN
mgtMTc2Ljc5YzU0LjEyLTI4LjY1IDY2LjE4LTY1LjA1IDY4LjY1LTExNi0xOC43MyAxNS4zOS01MC4yI
DM0LjI4LTkxLjgzIDM0LjI2LTM3LjI5IDAtOTEuMzQtMjguNzEtOTEuMzQtOTEuMzQgMC0xMTQuNDcgO
DAuNjQtODMuMzIgMjAyLjkxLTI3Ni40OSAxMjIuMjggMTkzLjE3IDIwMi45MiAxNjIuMDMgMjAyLjkyI
DI3Ni40OXoiLz48L3N2Zz4="
try:
image = base64.b64decode(base64_string, validate=True)
file_to_save = "my_image/png"
with open(file_to_save, "wb") as f:
f.write(image)
except binascii.Error as e:
print(e)
the code produces a tex type file, in fact it is an SVG file, change the
type and drop it on the !Netsurf icon, you got a "spade"
I tried with other "strings" and I got PNG which had been Base64 encoded.
To test with your string, no split needing.
--
Jean-Michel
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)