Welcome, Guest. Please Login.
IRobotSoft Robot
11/14/19 at 00:52:16
News: IRobotSoft is the Best Visual Web Computing Platform!
Home Help Search Login
Google
 


Pages: 1
Send Topic Print
How to save images (Read 11431 times)
tspiderus
Junior Member
**


I Love IRobotSoft

Posts: 12
How to save images
04/11/11 at 14:14:37
 
Quote:

IRobotSoft Administrator
How to save images
07/28/09 at 00:01:21   After you get each image_url, you can use:  
SaveUrlFile(image_url, local_file)  
 
to save it to a local_file.

 
I took a look in the iRobot manual, "SaveUrlFile" function.
 
Can you please let me know how to save images.  
 
Can you explain the two parameters image_url and local_file?
 
MY PROBLEM:
 
My robot gets the web images urls and stores them in the variable image_url (these urls are also saved, for reference, in an XML file). I've created an EVENT and used SaveUrlFile(image_url, local_file). However, images are not saved and no error messages are displayed.
 
PS: Is there any reason I cant post replyes in the "FAQ" section of this forum?
 
Thanks!
Back to top
 
 
  IP Logged
IRobotSoft Administrator
IRobotSoft Administrator
*****


IRobotSoft, the Best
Internet Robot
System

Posts: 1608
Gender: male
Re: How to save images
Reply #1 - 04/11/11 at 19:05:00
 
You can test this in your event:  
Event: After each tuple; Value: saveUrlFile('http://irobotsoft.org/logo.jpg', 'test.jpg')
this should save the irobotsoft logo in your current directory as test.jpg.  
 
Then you can change the first parameter with an image url you extracted.  
 
If it does not save your file, copy your image url and put it into a regular IE browser and see if it display the correct image.  
 
PS: you have to make enough posts to be able to post to the FAQ forum.
Back to top
 
 

The Administrator.
WWW   IP Logged
tspiderus
Junior Member
**


I Love IRobotSoft

Posts: 12
Re: How to save images
Reply #2 - 04/13/11 at 08:18:28
 
Quote from IRobotSoft Administrator on 04/11/11 at 19:05:00:
You can test this in your event:
Event: After each tuple; Value: saveUrlFile('http://irobotsoft.org/logo.jpg', 'test.jpg')
this should save the irobotsoft logo in your current directory as test.jpg.  

Then you can change the first parameter with an image url you extracted.  

If it does not save your file, copy your image url and put it into a regular IE browser and see if it display the correct image.

 
OK, It works. I used:
Code:
SaveUrlFile(url_image, strcat(external_id,'.jpg')) 

and the images are saved in root folder.  
 
'external_id' is an id for each product from a webpage and it's unique.
 
For better usability please explain me how to do the followig:
 
1. I want to save the file with its original name and extension.  
 
Eg: starting with your example: saveUrlFile('http://irobotsoft.org/logo.jpg', 'test.jpg'), I want to save the file with its original name: 'logo.jpg'. How should I use the saveUrlFile function?
 
Code:
SaveUrlFile(url_image, ??? ) 


 
2. How can I define (in the saveUrlFile function, or some other way) a FOLDER in which images are going to be saved?
Back to top
 
 
  IP Logged
IRobotSoft Administrator
IRobotSoft Administrator
*****


IRobotSoft, the Best
Internet Robot
System

Posts: 1608
Gender: male
Re: How to save images
Reply #3 - 04/13/11 at 10:00:08
 
You can use:  
Code:
GetFileName(url_image) 

to get the filename.  
 
To save to a directory, simply put the complete path in the filename, such as:  
Code:
SaveUrlFile(url_image, strcat('c:\\irobot\\data\\', GetFileName(url_image) ))  

 
 
 Finally, you may find this function useful from the manual:  
Code:
UniqueFileName = GetUniqueFileName(Dir, FileName, [SubDir]) 


Get a unique file name in Dir, or Dir/SubDir/, with the base name given in FileName. If Dir or Dir/SubDir/ does not exist, the directory will be created by this function. The returned UniqueFileName does not include the Dir or SubDir prefix.
Back to top
 
 

The Administrator.
WWW   IP Logged
tspiderus
Junior Member
**


I Love IRobotSoft

Posts: 12
Re: How to save images
Reply #4 - 04/13/11 at 16:07:01
 
Code:
SaveUrlFile(url_image, strcat('c:\\irobot\\data\\', GetFileName(url_image) )) 


 
It works like a charm.
 
Thanks!
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print