Solved

Load and Save Image

Posted on 2008-06-09
3
959 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now