Solved

Load and Save Image

Posted on 2008-06-09
3
963 Views
Last Modified: 2012-06-22
Hello, how can I load an image on another server and save it onto my server?  I tried the code below but fromfile doesnt accept URIs as a property.  Should I use httpwebrequest?  How can this be done?

        Dim originalImage As System.Drawing.Image
        originalImage = System.Drawing.Image.FromFile("http://domain.com/images/logo.jpg")
        originalImage.Save(...)

Thanks Very Much!
0
Comment
Question by:grogo21
3 Comments
 
LVL 14

Accepted Solution

by:
rachitkohli earned 100 total points
ID: 21748842
Am writing a rough code.. alter it for accuracy..

     Dim myReq As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
     Dim myResp As WebResponse = myReq.GetResponse()
   
     Dim stream As Stream = myResp.GetResponseStream()
     myResp.Close()

' Now use stream object for creating the image.
        Dim bm As Image
        bm=image.FromStream(stream)

0
 
LVL 18

Assisted Solution

by:Ajay Sharma
Ajay Sharma earned 100 total points
ID: 21748882
0
 
LVL 8

Assisted Solution

by:YoungBonzi
YoungBonzi earned 100 total points
ID: 21749353
simple way:
program a way to set the url and localFile variables
myWebClient.DownloadFile(url, localPath & localFile)
        Imports System.Net
----------------
 
        Dim myWebClient As New WebClient()
        Dim url As String = "http://www.google.com/intl/en_ALL/images/logo.gif"
        Dim localPath As String = Server.MapPath("Your_Image_Folder\")
        Dim localFile As String = "some_image.gif" 
 
        myWebClient.DownloadFile(url, localPath & localFile)

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question