Below I try to do this using just the Base64 module.
MWE
using Base64
using Downloads
using FileIO
path = Downloads.download("https://github.com/MakieOrg/Makie.jl/raw/master/assets/doge.png")
img = load(path)
# reduce quality a bit, otherwise firefox complains
img = img[1:4:end,1:4:end]
w, h = size(img)
encoded_img = base64encode(img)
svg = """
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<image width="$w" height="$h" xlink:href="data:image/png;base64,$encoded_img"/>
</svg>
"""
open("/tmp/mwe.svg", "w") do f
write(f, svg)
end
Unfortunately, my Firefox says that this image contains errors.
I also tried converting the image to RGBf first and then encode it, but without success.
I also looked into Images.jl’s docs but nowhere is something mentioned about base64 encoding.