ImageSource vs. <img src="your image"> ?

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

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: ImageSource vs. <img src="your image"> ?

Post by mwieder » Tue May 11, 2021 4:25 pm

OK, I get that, but...

it seems like you're dealing with a small fixed set (half dozen or so?) of images. Why not just download them once from the website, import them into the stack and store them on a separate card, size them (or not) and just set the imagesource of the char when desired? That's been my approach when I need to do similar tasks.

Also... my experience in an earlier life scraping web sites is that both the content and format of web pages changes much more often than I'd like, and then I'd have to go through the process not just of updating my code, but of painfully examining the page source of the original page to see what changed and what I'd need to do to get at the new data. If there's an api to work with it's gonna be much more stable because the folks who are putting the web pages together are gonna need it that way as well. Registering for an api key with weather underground is free - I use it to display current weather on osmc running on a raspberry pi.

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

Re: ImageSource vs. <img src="your image"> ?

Post by bogs » Tue May 11, 2021 5:56 pm

mwieder wrote:
Tue May 11, 2021 4:25 pm
it seems like you're dealing with a small fixed set (half dozen or so?) of images. Why not just download them once from the website, import them into the stack and store them on a separate card, size them (or not) and just set the imagesource of the char when desired?
Perfectly legit way to go, but the main reason I am not doing that (in this or any other app I write) is two fold-
1. size - while these pictures are relatively small, weighing in anywhere from 3 to 15kb, if I decide to use larger images, the size of the stack would grow quite quickly.
2. the number of pictures involved - as far as I can tell, there is an image for not only every day / night of the week, but also for every situation that might come up. Sunday, for instance, looks like this...
Sunday.png
Sunday looks chancey...
Sunday.png (9.57 KiB) Viewed 1200 times
Monday ...
Monday.png
Monday looks none too trustworthy either...
Monday.png (12.28 KiB) Viewed 1200 times
I took the easy way out here, of the methods I tested, downloading them to the folder took no time at all compared to, as I mentioned earlier, putting them directly into an image object. Now, I might not have the most efficient code rolling, that is true, but out of what I can do, just downloading and popping them in is the easiest / fastest so far by enough, and whatever comes down replaces whatever was in the folder, so the size issue is no issue at all, at least while using imageSource.
Also... my experience in an earlier life scraping web sites is that both the content and format of web pages changes much more often than I'd like, and then I'd have to go through the process not just of updating my code, but of painfully examining the page source of the original page to see what changed and what I'd need to do to get at the new data. If there's an api to work with it's gonna be much more stable because the folks who are putting the web pages together are gonna need it that way as well. Registering for an api key with weather underground is free - I use it to display current weather on osmc running on a raspberry pi.
I already agree for anyone else, or even myself, using the API would be easier heh, and NOAA already has a free use for registration API, I just don't feel like registering for any of them, and as I said, I wanted to experiment with scraping. So far, the target lines I've picked out seem to be pretty stable, but if they change I doubt it would be that painstaking to pick them out again, FF makes it quite easy indeed :wink:
Image
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”