Page 1 of 1
Save online picture in memory
Posted: Sat Apr 25, 2015 5:49 pm
by croivo
I'm having troubles trying to load images from internet. I use this code on a button:
Code: Select all
set the filename of image myImage to "http://mysite.com/myimage.png"
However, this doesn't load images every time. Also, how to save that image in the stack so that if I compile app with that image (set as source of image holder) it doesn't dissapear (if there is no internet connection)?
Re: Save online picture in memory
Posted: Sat Apr 25, 2015 6:11 pm
by richmond62
The best way to save an image in a stack is to download it to your computer using a web-browser and then import it.
I have never tried importing an image directly from the internet . . .
I just tried this:
on mouseUp
import paint from file "
http://newsletters.livecode.com/septemb ... chmond.jpg"
end mouseUp
and got this:
executing at 8:04:34 PM
Type import: can't open file, mask file or display
Object Button
Line import paint from file "
http://newsletters.livecode.com/septemb ... chmond.jpg"
Hint
http://newsletters.livecode.com/septemb ... chmond.jpg
tried this:
on mouseUp
import paint from file it with mask "
http://newsletters.livecode.com/septemb ... chmond.jpg"
end mouseUp
and LiveCode had a problem with 'it'.
Re: Save online picture in memory
Posted: Sun Apr 26, 2015 1:01 pm
by Klaus
Obviously "import paint from file..." only works with local files.
You need to do download the image to your machine first like this:
...
put url "
http://mysite.com/myimage.png" into url("binfile:" & speciafolderpath("documents") & "/myimage.png")
...
And use that new local file.
Re: Save online picture in memory
Posted: Sun Apr 26, 2015 7:06 pm
by jacque
This works to load an image from a web URL:
Code: Select all
set the text of img 1 to url "http://www.domain.com/images/img.png"
That will load the image content from the web directly into the image object. Since the the image is now imported rather than referenced, saving the stack will save the image as well.
I'm having troubles trying to load images from internet. I use this code on a button:
set the filename of image myImage to "
http://mysite.com/myimage.png"
However, this doesn't load images every time.
If this only fails some of the time, the most likely reason is an incorrect URL. You might get more information about the cause of the error if you check the result after issuing the command:
Code: Select all
set the filename of image myImage to "http://mysite.com/myimage.png"
if the result is not empty then answer the result
Re: Save online picture in memory
Posted: Thu Apr 30, 2015 6:50 pm
by croivo
Thanks Jacque! That's what I was looking for

Re: Save online picture in memory
Posted: Thu Feb 25, 2016 11:41 pm
by croivo
Just one more dumb question (I'll ask here so I don't open million new topics):
How do I set filename of image to other image?
Let's say I have imported image in stack and I want to set the filename of another image to be the same as the image that is imported?
Re: Save online picture in memory
Posted: Fri Feb 26, 2016 12:10 am
by dunbarx
Hi.
Do you mean set the "filename"? See the dictionary.
Criaig Newman
Re: Save online picture in memory
Posted: Fri Feb 26, 2016 5:53 am
by jacque
croivo wrote:How do I set filename of image to other image?
Let's say I have imported image in stack and I want to set the filename of another image to be the same as the image that is imported?
The filename is only used to refer to a file on disk. If an image is already imported, it has no filename, it is now a part of the stack. The content of an image is its "text" property. So to put the content of an imported image into another image:
Code: Select all
set the text of img 2 to the text of img 1