If you just assign a URL to a TGraphic and then call SaveToStream, the stream actually is empty. The reason is that TGraphic.SaveToStream only works as expected with a canvas. It would be nice to make SaveToStream work, if just a URL has been set.
That is non-trivial and actually, offering this synchronous won’t be possible as requesting data from an URL is always asynchronous. We will investigate but at first sight, best we can do is a promise based helper function.
It would suffice to handle URLs of the form data:..base64 where all the data is already there.
What is already there is in WEBLib.Utils.pas :
function Base64ToArrayBuffer(Base64: string): TJSArrayBuffer;
and then you can use TMemoryStream.MemoryToBytes(Mem : TJSArrayBuffer) : TBytes
use use a TMemoryStream.Write() to write this TBytes buffer to the TMemoryStream