reading a jpg file and resizing it on the fly ?

K

Koen Hoorelbeke

Hi there,

I want to read a jpg-file from a url (f.e. http://someserverWhichIsNOTLocal/images/test.jpg), get the dimensions, resize it, save it to my local disk on the webserver as a gif-image and next show it on my own (mobile) pages. (Actually I'm reading some images from my normal website, which is on another machine, resize them, and show them on my mobile site ...).

The main problem lies in reading the image from a url ... can't seem to find how I should do that.

I'd like to be able to do something like :
thumb = System.Drawing.Image.FromFile("http://someserverWhichIsNOTLocal/images/test.jpg")
But unfortunately that doesn't work.

Any ideas?

Thanks in advance.

Greetingz,
Koen Hoorelbeke
(e-mail address removed)
 
P

Patrick Steele [MVP]

Hi there,

I want to read a jpg-file from a url (f.e. http://someserverWhichIsNOTLocal/images/test.jpg), get the dimensions, resize it, save it to my local disk on the webserver as a gif-image and next show it on my own (mobile) pages. (Actually I'm reading some images from my normal website, which is on another machine, resize them, and show them on my mobile site ...).

The main problem lies in reading the image from a url ... can't seem to find how I should do that.

I'd like to be able to do something like :
thumb = System.Drawing.Image.FromFile("http://someserverWhichIsNOTLocal/images/test.jpg")
But unfortunately that doesn't work.

"Creating an image from a URL"
http://weblogs.asp.net/psteele/posts/7533.aspx
 
K

Kevin Spencer

The problem is that you're using a method which gets a file from a file
system, not an HTTP request, which is what you need to get an image from a
URL. What you need to do is to use a WebRequest to download the image and
then you can work with it. Here is a reference in the MSDN Library online
which should help:

http://msdn.microsoft.com/library/d.../cpconusinginternetrequestresponseclasses.asp

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

Hi there,

I want to read a jpg-file from a url (f.e.
http://someserverWhichIsNOTLocal/images/test.jpg), get the dimensions,
resize it, save it to my local disk on the webserver as a gif-image and next
show it on my own (mobile) pages. (Actually I'm reading some images from my
normal website, which is on another machine, resize them, and show them on
my mobile site ...).

The main problem lies in reading the image from a url ... can't seem to find
how I should do that.

I'd like to be able to do something like :
thumb =
System.Drawing.Image.FromFile("http://someserverWhichIsNOTLocal/images/test.
jpg")
But unfortunately that doesn't work.

Any ideas?

Thanks in advance.

Greetingz,
Koen Hoorelbeke
(e-mail address removed)
 
K

Koen Hoorelbeke

Great ! Just what I needed.

Tx !

Greetingz,
Koen.

http://someserverWhichIsNOTLocal/images/test.jpg), get the dimensions,
resize it, save it to my local disk on the webserver as a gif-image and next
show it on my own (mobile) pages. (Actually I'm reading some images from my
normal website, which is on another machine, resize them, and show them on
my mobile site ...).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top