Downloading .JPG from web
Posted
#1
(In Topic #795)
Regular

This text file works fine:
Code
File.save(ImageFilePath &/ "test.txt", HttpClient.Download("https://moz.com/robots.txt"))This jpg works fine:
Code
File.save(ImageFilePath &/ "testPic.jpg", HttpClient.Download("https://upload.wikimedia.org/wikipedia/commons/thumb/f/f4/Gamba.JPG/90px-Gamba.JPG"))This one is thumb'n it's nose at me:
Code
File.save(ImageFilePath &/ "test4.jpg", HttpClient.Download("https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/se/15/20213631716_GOES16-ABI-se-15-1200x1200.jpg"))Code
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.20.1</center>
</body>
</html>
Posted
Regular

…if you want to try extern Curl libraryDiverod said
I can't get it to work with curl or wget
Code (gambas)
- Library "libcurl:4.8.0"
- ' CURL *curl_easy_init(void)
- ' Start a libcurl easy session.
- ' CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...)
- ' Set options for a curl easy handle
- ' CURLcode curl_easy_perform(CURL *curl)
- ' Perform a blocking file transfer.
- ' const char *curl_easy_strerror(CURLcode)
- ' Turn a CURLcode value into the equivalent human readable error string.
- ' void curl_easy_cleanup(CURL *curl)
- ' End a libcurl easy handle.
- Library "libc:6"
- ' FILE *fopen (const char *__restrict __filename, const char *__restrict __modes)
- ' Open a file and create a new stream for it.
- ' int fclose (FILE *__stream)
- ' Close STREAM.
- ' Web address of JPG image-file, that you want to download:
- ' Sets the path (and file name) where JPG image-file will be re-created:
- final_file = "/tmp/file.jpg"
- cu = curl_easy_init()
- curl_easy_setopt(cu, CURLOPT_URL, url)
- fl = fopen(final_file, "wb")
- curl_easy_setopt(cu, CURLOPT_WRITEDATA, fl)
- ' Writes new JPG image file:
- ris = curl_easy_perform(cu)
- ' Free memory:
- fclose(fl)
- curl_easy_cleanup(cu)
…if you want to try "wget" with Gambas:
Code (gambas)
- ' It will download the image file to the "/tmp" folder.
- ' The Process of the "wget" command, launched by the "Shell" instruction, will be opened for "Read" to obtain the messages sent by the aforementioned Process in the console/Terminal.
- Line Input #Last, s
- Print s
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Banned
https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/se/15/
you'll see the file does not exist
Posted
Regular

vuott said
…if you want to try "wget" with Gambas:Code (gambas)
' It will download the image file to the "/tmp" folder. ' The Process of the "wget" command, launched by the "Shell" instruction, will be opened for "Read" to obtain the messages sent by the aforementioned Process in the console/Terminal. Line Input #Last, s Print s
Thank you very much vuott! The wget code worked perfect in Gambas for all cases tried.
I've been reading the "man" page on curl and find it a bit overwhelming at this point for me but your code using a curl library is very helpful in understanding some of it. Thanks, RodG.
Posted
Regular

BruceSteers said
If you look at this page…
https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/se/05/
you'll see the file does not exist
Okay, Bruce, now I feel stupid
Code
https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/se/15/20220032041_GOES16-ABI-se-15-300x300.jpgThanks for letting me know because I might have been still chasing that one for a while. RodG
Posted
Trainee

Posted
Banned
Mitin77 said
Downloading .JPG files from the web is a straightforward process. Right-click on the image and select "Save image as" to choose a destination on your device. Ensure the file name is descriptive for easy identification later. Enjoy your new images!
Erm , this is a Gambas Basic forum and that has nothing to do with how you download images using gambas basic.
OP probably knows how to download images using their web browser.
Posted
Trainee

I ran into something similar while editing weather time lapse sequences. I needed to find consistent file formats that wouldn’t glitch during import. I found this helpful list of the best AVI video editors https://www.movavi.com/learning-portal/best-avi-video-editors.html when sorting that out, you might find something useful there if you're planning to edit image sequences into videos later.
1 guest and 0 members have just viewed this.





