Hello,
I haven't tested it, but this function might be useful for you: img.GetPixelData
This function returns a base64 string. You may need to use atob to decode it.
Dave's comment on an old post:
“rawbase64” or “pngbase64”, “jpgbase64”, "json"
rawbase64 can also be combined with the 'grayscale' option which is faster and results in a smaller image (useful for image processing)