Getting a data image from browser

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Getting a data image from browser

Post by doobox » Fri Apr 15, 2016 5:27 pm

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?
Kind Regards
Gary

https://www.doobox.co.uk

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Getting a data image from browser

Post by doobox » Fri Apr 15, 2016 5:57 pm

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.
Kind Regards
Gary

https://www.doobox.co.uk

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”