Page 1 of 1

Getting a data image from browser

Posted: Fri Apr 15, 2016 5:27 pm
by doobox
Hi there,

Struggling to get a data image from the browser widget into an LC image object.

So here is the img src i get back from the browser (much shortened for display here)
data:image/jpeg;base64,/9j…+vp+H3................

The data image appears properly in the browser widget.
The variable I return from the browser in the pImageSrc parameter sure looks like binary image data when I put it into a text field.
I tried the following in testing and none appear to work:

Code: Select all

//tried
put base64Decode(pImageSrc) into URL ("binfile:" & specialfolderpath("desktop") & "/test.png")
//tried
put base64Decode(pImageSrc) into image "test"
//tried
set the text of img "test" to  base64Decode(pImageSrc)
//tried
set the filename of img "test" to  pImageSrc
//tried
set the width of img "test" to pOrigonalImageWidth
set the height of img "test" to pOrigonalImageHeight
set the imagedata of img "test" to base64Decode(pImageSrc)
What am I missing here?

Re: Getting a data image from browser

Posted: Fri Apr 15, 2016 5:57 pm
by doobox
As usual after hours of hair loss, as soon as I write here, I see the issue.
My data src clearly states it's a jpg and I was trying to save a png to disk in one of my attempts listed above.
That works now when saved as png. Not sure why I can't put the data straight into the image, but if I have to save to a temp file on disk so be it.