Page 1 of 1
Image link option
Posted: Wed Apr 08, 2026 8:46 pm
by Natter
Hi,
There is a link to the picture on someone else's website.
Is it possible to pull out an image and save it as a file?
Re: Image link option
Posted: Fri Aug 28, 2026 3:50 pm
by AiBot
Hello,
Yes, it is possible to download an image from a URL and save it as a file using Harbour or xHarbour. You can use network functions to fetch the image data and then write it to a local file.
For example, in Harbour, you might use the `hDownload()` function from the HbNet library:
[code]
Local cUrl := "https://example.com/path/to/image.jpg"
Local cLocalFile := "downloaded_image.jpg"
IF hDownload( cUrl, cLocalFile )
? "Image saved successfully to", cLocalFile
ELSE
? "Error downloading image"
ENDIF
[/code]
Make sure that your project includes the necessary network libraries (like `hbnet`) and that you handle any exceptions or errors appropriately. If you're working in a specific framework like FiveWin, check the documentation for built-in functions or classes that might simplify this process.
If you need more details or have further questions, feel free to ask!
---
Respuesta generada por Inteligencia Artificial usando el modelo mimo-v2.5-free via OpenCode Zen. Puede contener errores; por favor verifiquela antes de aplicar.
AI-generated reply using the mimo-v2.5-free model via OpenCode Zen. May contain mistakes; please verify before applying.
Re: Image link option
Posted: Sat Aug 29, 2026 2:33 pm
by karinha
Code: Select all | Expand
// C:\FWH2603\SAMPLES\IMGDOWN2.PRG
#include "Fivewin.ch"
REQUEST HB_GT_GUI_DEFAULT
FUNCTION Main()
IF FILE( "c:\TEMP\Imagem2.jpg" )
DELETEFILE( "c:\TEMP\Imagem2.jpg" )
ENDIF
MsgRun( "Aguarde o Download...", "Espere", { || DownloadFile() } )
RETURN NIL
FUNCTION DownloadFile()
LOCAL oServerWS, oADODBStream
#ifdef __XHARBOUR__ // PERFEITO COM XHARBOUR( I Like )
Try
Try
oServerWS := CreateObject( 'MSXML2.XMLHTTP' )
Catch
oServerWS := CreateObject( 'Microsoft.XMLHTTP' )
End
Catch
MsgInfo( 'Erro na Criação do Serviço' )
RETURN NIL
End
#else
Try
Try
oServerWS := win_OleCreateObject( 'MSXML2.XMLHTTP' )
Catch
oServerWS := win_OleCreateObject( 'Microsoft.XMLHTTP' )
End
Catch
MsgInfo( 'Erro na Criação do Serviço! Com Harbour', 'Atenção!' )
RETURN NIL
End
#endif
oADODBStream := CREATEOBJECT( "Adodb.Stream" )
oServerWS:Open( "GET", "https://i.oneme.ru/i?r=BTE2sh_eZW7g8kugOdIm2Notn5Uj_vutw0JZOuoJpRlHQwUfwMhzHGGtcQEW7VWfF3I", .F. )
oServerWS:Send()
oADODBStream:Type := 1
oADODBStream:Open()
oADODBStream:Write( oServerWS:ResponseBody )
oADODBStream:SaveToFile( "c:\TEMP\Imagem2.jpg", 2 )
IF FILE( "c:\TEMP\Imagem2.jpg" )
MsgInfo( "Imagem baixada com sucesso!", "Sucesso" )
ELSE
MsgStop( "Erro ao baixar a imagem.", "Erro" )
ENDIF
RETURN NIL
// FIN / END
Regards, saludos.
Re: Image link option
Posted: Sat Aug 29, 2026 2:35 pm
by karinha
Code: Select all | Expand
// C:\FWH2603\SAMPLES\IMGDOWN.PRG
#include "fivewin.ch"
REQUEST HB_GT_GUI_DEFAULT
FUNCTION Main()
LOCAL cUrl := "https://i.oneme.ru/i?r=BTE2sh_eZW7g8kugOdIm2Notn5Uj_vutw0JZOuoJpRlHQwUfwMhzHGGtcQEW7VWfF3I"
LOCAL cLocal := "c:\TEMP\imagem.jpg"
LOCAL nRet
nRet := URLDownloadToFile( 0, cUrl, cLocal, 0, 0 )
IF nRet == 0
MsgInfo( "Imagem baixada com sucesso!", "Sucesso" )
ELSE
MsgStop( "Erro ao baixar a imagem.", "Erro" )
ENDIF
RETURN NIL
DLL32 FUNCTION URLDownloadToFile( pUnk AS LONG, cURL AS LPSTR, cFileName AS LPSTR, nReserved AS LONG, nFnCB AS LONG ) AS LONG ;
PASCAL FROM "URLDownloadToFileA" ;
LIB "urlmon.dll"
Regards, saludos.