how can I load a website url into an image control

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Bevan
Posts: 18
Joined: Sat Jan 13, 2018 1:37 am

how can I load a website url into an image control

Post by Bevan » Fri Mar 08, 2019 11:01 pm

Hi,

Instead of using the browser widget to load a url, how can I load a website url into an image control?

I have a scroller as a graphical menu, however the scroller doesn't work when i have a browser in the scroll group. Therefore at the end of the scrolling graphic menu I want to add a image control linked to a URL website. The image control will display a blog article with graphics and text from the website, which will be included in the scrolling graphic menu.

Thanks,
Bevan.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: how can I load a website url into an image control

Post by bogs » Fri Mar 08, 2019 11:06 pm

Just throwing this out there, but couldn't you load the page in the browser control, then export a snapshot of it and import that snapshot into the image control?

Seems like a clunky way to go about it though..
Image

Bevan
Posts: 18
Joined: Sat Jan 13, 2018 1:37 am

Re: how can I load a website url into an image control

Post by Bevan » Fri Mar 08, 2019 11:49 pm

thanks for the suggestion, a good idea but a bit clunky like you said, can you load into a browser and instead of import/export can you set the image control to browser contents?

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: how can I load a website url into an image control

Post by Klaus » Sat Mar 09, 2019 1:39 am

Hi Bevan,
Bevan wrote:
Fri Mar 08, 2019 11:49 pm
thanks for the suggestion, a good idea but a bit clunky like you said, can you load into a browser and instead of import/export can you set the image control to browser contents?
no.


Best

Klaus

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: how can I load a website url into an image control

Post by MaxV » Mon Apr 22, 2019 10:27 pm

Code: Select all

put URL "http://www.runrev.com/images/logo.jpg" into image "web"
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: how can I load a website url into an image control

Post by bogs » Mon Apr 22, 2019 10:40 pm

Yes that would work Max, but only for an image you have an address for. I am pretty sure the OP wants to load an actual page into an image object.

Sorry Bevan, I never did find any less clunky way to do this.
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: how can I load a website url into an image control

Post by FourthWorld » Tue Apr 23, 2019 1:29 am

The literally millions of machine instructions needed to download all of the elements of a web page and render them is inherently time consuming.

There is no magic pony to make that much simpler. Web page rendering is a very complex task.

Though it may seem klunky, given the complexity of the task Bogs' suggestion is about as simple as nearly anything you'll find for this anywhere on this planet.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: how can I load a website url into an image control

Post by SparkOut » Tue Apr 23, 2019 7:40 am

I'm sure Hermann put up a scrolling browser thumbnailer stack somewhere, didn't he?

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: how can I load a website url into an image control

Post by bogs » Tue Apr 23, 2019 10:10 am

Dunno, but if anyone would have, I'm sure it would be Hermann :D
FourthWorld wrote:
Tue Apr 23, 2019 1:29 am
Though it may seem klunky, given the complexity of the task Bogs' suggestion is about as simple as nearly anything you'll find for this anywhere on this planet.
I know Firefox (and probably most other browsers) have the ability to produce an image of a webpage in full, so I suppose if you can find out a cli way of initiating it, then put it on your card as a group, you'd have a picture of the webpage with the ability to scroll it as well.

For Firefox, the cli would be
Boolean World
Firefox
Firefox 57 and later versions features a command-line screenshot mode. Just like pageres-cli, Firefox captures webpages accurately, but it doesn’t have as many features. This mode doesn’t make use of a graphical environment, which makes it well-suited for usage on servers.

To take a screenshot with Firefox, run:

firefox -screenshot google.png google.com

This creates a full-page screenshot of google.com to the file google.png. At present, Firefox doesn’t support creating screenshots in other formats. If you use a different extension like google.jpg, it will create a PNG file with that name.

To take a size-limited screenshot, use the --window-size parameter. For example, if you want to generate a screenshot of size 1366×768, run:
The only problem there of course is determining what browser the user might have on their system, because for it to work, you'd have to know which command to issue. Of course, it would also depend on whether you were able to use shell or not to issue the command. I know it doesn't work on some 'nix and mac systems.
Image

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: how can I load a website url into an image control

Post by [-hh] » Tue Apr 23, 2019 10:37 am

This is very simple with LiveCode
= use javascriptHandlers for scrolling the page,
= export snapshot for generating the corresponding image part,
= build the image from the image parts.

See
viewtopic.php?p=174346#p174346
shiftLock happens

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: how can I load a website url into an image control

Post by SparkOut » Tue Apr 23, 2019 12:57 pm

I *knew* there was a magical Hermann solution somewhere close at hand :D

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: how can I load a website url into an image control

Post by FourthWorld » Tue Apr 23, 2019 1:54 pm

SparkOut wrote:
Tue Apr 23, 2019 12:57 pm
I *knew* there was a magical Hermann solution somewhere close at hand :D
Yes, it's very well done. As Bogs suggested, it relies on a browser engine (Widget) to render the page, then uses LC's snapshot to obtain the rendered page image.

Though Bevan had considered this method clunky, I can't imagine attempting to render modern HTML without a browser engine. And in Hermann's capable hands, LC is shown to provide this about as easily as it can get.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”