473,545 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Saving TIF Image from the Internet

I have an app that (at the moment) moves through files that are on a web
site, and deletes them, wat i want to do for the next stage, is to be able to
download each file before i delete it.

i have tried POSTin to be able to view the image, then saving it, but it
doesnt work, the problem i have is that all the files on the server have the
same name, which is
http://1.1.1.1/DH/repository/content.tif

and for me to be able to view one, i had to send the follow command (that
has a fwe ids that tell me the server which file i want)

show=&did=31374 &rid=6_2_6_1_2_ 1&sid=174709756 905990&WidthSiz e=136&useSavedP aram=&dummy=

once i did this i got the followin content response

HTTP/1.1 200 OK
Server: Web-Server/3.0 GW-Repository
Content-Length: 24434
Content-Type: image/x-tiff
Set-Cookie: cookieOnOffChec ker=on; path=/
Connection: close

MM

i have tried to use the
WebClient.Downl oadData(http://1.1.1.1/DH/repository/content.tif)

but it simply returns an error.

Does enyone have any ideas.
Thanx in advance
Nov 17 '05 #1
5 3127
Thaynann,

What is the error that you are getting? You should be able to set the
query string using the web client as well, and get the correct response, for
you to save.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Thaynann" <Th******@discu ssions.microsof t.com> wrote in message
news:44******** *************** ***********@mic rosoft.com...
I have an app that (at the moment) moves through files that are on a web
site, and deletes them, wat i want to do for the next stage, is to be able
to
download each file before i delete it.

i have tried POSTin to be able to view the image, then saving it, but it
doesnt work, the problem i have is that all the files on the server have
the
same name, which is
http://1.1.1.1/DH/repository/content.tif

and for me to be able to view one, i had to send the follow command (that
has a fwe ids that tell me the server which file i want)

show=&did=31374 &rid=6_2_6_1_2_ 1&sid=174709756 905990&WidthSiz e=136&useSavedP aram=&dummy=

once i did this i got the followin content response

HTTP/1.1 200 OK
Server: Web-Server/3.0 GW-Repository
Content-Length: 24434
Content-Type: image/x-tiff
Set-Cookie: cookieOnOffChec ker=on; path=/
Connection: close

MM

i have tried to use the
WebClient.Downl oadData(http://1.1.1.1/DH/repository/content.tif)

but it simply returns an error.

Does enyone have any ideas.
Thanx in advance

Nov 17 '05 #2
There is no specific message with the exception...jus t says "Error has
occured in WebClient", i tried grabbing the InnerException, and the
staceTrace, but no actual message with exception, just above.

i have another idea as to how to save it, that is to create a file (probably
with a FileStream) then simply write the response bytes straight to it. im
hopin this will work. ill keep u posted

"Nicholas Paldino [.NET/C# MVP]" wrote:
Thaynann,

What is the error that you are getting? You should be able to set the
query string using the web client as well, and get the correct response, for
you to save.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Thaynann" <Th******@discu ssions.microsof t.com> wrote in message
news:44******** *************** ***********@mic rosoft.com...
I have an app that (at the moment) moves through files that are on a web
site, and deletes them, wat i want to do for the next stage, is to be able
to
download each file before i delete it.

i have tried POSTin to be able to view the image, then saving it, but it
doesnt work, the problem i have is that all the files on the server have
the
same name, which is
http://1.1.1.1/DH/repository/content.tif

and for me to be able to view one, i had to send the follow command (that
has a fwe ids that tell me the server which file i want)

show=&did=31374 &rid=6_2_6_1_2_ 1&sid=174709756 905990&WidthSiz e=136&useSavedP aram=&dummy=

once i did this i got the followin content response

HTTP/1.1 200 OK
Server: Web-Server/3.0 GW-Repository
Content-Length: 24434
Content-Type: image/x-tiff
Set-Cookie: cookieOnOffChec ker=on; path=/
Connection: close

MM

i have tried to use the
WebClient.Downl oadData(http://1.1.1.1/DH/repository/content.tif)

but it simply returns an error.

Does enyone have any ideas.
Thanx in advance


Nov 17 '05 #3
Nicholas,

i have managed to get the image to save, by using the following code

Stream stream = webResponse.Get ResponseStream( );
Stream imageFile = File.Create(@"C :\IMAGES\image. tif");
Bitmap b = new Bitmap(stream);
b.Save(imageFil e, ImageFormat.Tif f);

which works fine, the only problem is that, most of the fils im tryin to
save off teh web page are multi-page Tif files, and using the code above, it
seems to be only saving the first page,

i thought maybe the content returned from the server maybe only for the
first page, but i ran the web page via IE (with Fiddler running) and the
commands are identical to wat i have to view the image and IE lets me move
through the multiple pages of the image,

Any ideas?
Thanx for your help so far.
"Nicholas Paldino [.NET/C# MVP]" wrote:
Thaynann,

What is the error that you are getting? You should be able to set the
query string using the web client as well, and get the correct response, for
you to save.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Thaynann" <Th******@discu ssions.microsof t.com> wrote in message
news:44******** *************** ***********@mic rosoft.com...
I have an app that (at the moment) moves through files that are on a web
site, and deletes them, wat i want to do for the next stage, is to be able
to
download each file before i delete it.

i have tried POSTin to be able to view the image, then saving it, but it
doesnt work, the problem i have is that all the files on the server have
the
same name, which is
http://1.1.1.1/DH/repository/content.tif

and for me to be able to view one, i had to send the follow command (that
has a fwe ids that tell me the server which file i want)

show=&did=31374 &rid=6_2_6_1_2_ 1&sid=174709756 905990&WidthSiz e=136&useSavedP aram=&dummy=

once i did this i got the followin content response

HTTP/1.1 200 OK
Server: Web-Server/3.0 GW-Repository
Content-Length: 24434
Content-Type: image/x-tiff
Set-Cookie: cookieOnOffChec ker=on; path=/
Connection: close

MM

i have tried to use the
WebClient.Downl oadData(http://1.1.1.1/DH/repository/content.tif)

but it simply returns an error.

Does enyone have any ideas.
Thanx in advance


Nov 17 '05 #4
Thaynann wrote:
Nicholas,

i have managed to get the image to save, by using the following code

Stream stream = webResponse.Get ResponseStream( );
Stream imageFile = File.Create(@"C :\IMAGES\image. tif");
Bitmap b = new Bitmap(stream);
b.Save(imageFil e, ImageFormat.Tif f);


You can dump the bytes read from the response stream directly to your
destination file. This can be refactored into a neat helper method.

public void Download(string url, string fileName)
{
// Add error handling for null params and other evil
// stuff on your own ;-)
HttpWebRequest request = (HttpWebRequest ) WebRequest.Crea te(url);
HttpWebResponse response = (HttpWebRespons e) request.GetResp onse();

using (Stream responseStream = response.GetRes ponseStream())
using (FileStream fileStream =
new FileStream(file Name, FileMode.Create ))
{
Copy(responseSt ream, fileStream);
}
}

public void Copy(Stream source, Stream target)
{
// Add error handling for null params and other evil
// stuff on your own ;-)
byte[] buffer = new byte[0x1000];
int bytes;
try
{
while ((bytes = source.Read(buf fer, 0, buffer.Length)) > 0)
{
target.Write(bu ffer, 0, bytes);
}
}
finally
{
target.Flush();
}
}

Note that there's also Webclient.Downl oadFile(), which wraps these
tasks nicey ;-)

cheers,
--
http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e
Nov 17 '05 #5
Thanx for the code, i managed to get it working, with the code u gave me, i
tried to use the webClient.Downl oadFile(), but i couldnt, i didnt have diret
access to the URL of the images, as all the Images i was getting had the
exact same URL, the only way to distinguish between each image was via IDs
that the server return when i posted requests.

thanx again for ur input, the app works perfectly, it was deployed yesterday

"Joerg Jooss" wrote:
Thaynann wrote:
Nicholas,

i have managed to get the image to save, by using the following code

Stream stream = webResponse.Get ResponseStream( );
Stream imageFile = File.Create(@"C :\IMAGES\image. tif");
Bitmap b = new Bitmap(stream);
b.Save(imageFil e, ImageFormat.Tif f);


You can dump the bytes read from the response stream directly to your
destination file. This can be refactored into a neat helper method.

public void Download(string url, string fileName)
{
// Add error handling for null params and other evil
// stuff on your own ;-)
HttpWebRequest request = (HttpWebRequest ) WebRequest.Crea te(url);
HttpWebResponse response = (HttpWebRespons e) request.GetResp onse();

using (Stream responseStream = response.GetRes ponseStream())
using (FileStream fileStream =
new FileStream(file Name, FileMode.Create ))
{
Copy(responseSt ream, fileStream);
}
}

public void Copy(Stream source, Stream target)
{
// Add error handling for null params and other evil
// stuff on your own ;-)
byte[] buffer = new byte[0x1000];
int bytes;
try
{
while ((bytes = source.Read(buf fer, 0, buffer.Length)) > 0)
{
target.Write(bu ffer, 0, bytes);
}
}
finally
{
target.Flush();
}
}

Note that there's also Webclient.Downl oadFile(), which wraps these
tasks nicey ;-)

cheers,
--
http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2164
by: mchl gdbt | last post by:
Hi, I have several thousand tiffs generated by application A which are read by application B. I need to remove a few colours from the tiffs and I decided to try with the python imaging library. Running under debug mode permits saving my tiff files (with Image.DEBUG=0, the save doesn't work! see below) , but it truncates the crazy tags in...
4
48193
by: Michael Kennedy [UB] | last post by:
Hi Everyone, I have this multithreaded C# windows forms application which does a lot of image processing. Occasionally, I get the following error: A generic error occurred in GDI+. System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,...
7
2074
by: Dobedani | last post by:
Dear All, I am developing / maintaining a web application which generates GIF images on the fly. When I send the image, I make sure a header is sent first with MIME-type image/gif. My HTML-code to show the image looks like this: <IMG SRC="http://myserver/scripts/mycgi.exe?page=graphsym&favid=myfav4&numlines=1&key=18" BORDER="0">
4
4241
by: CodeRazor | last post by:
I'm unfamiliar with image manipulation using c#. How can i resize a jpg that currently exists in a file and save it resized as a new file. The examples i've found have been a bit misleading for my particular requirements.
4
3275
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any errors. After reading the ole object from db, I saved it to C: as file1.bmp and displayed on the web. But it can not be displayed. After I manually sent...
16
1743
by: Fred | last post by:
hi, is there some way to prevent(at least for not so advanced users) image saving on local disk; currently i use javascript which handles the right mouse button click, but all it takes is to disable js in the browser ? TIA
5
4718
by: TheGanjaMan | last post by:
Hi everyone, I'm trying to write up a simple image stamper application that stamps the Exif date information from the jpegs that I've taken from my digital camera and saves the new file with the date stamped on the lower right part of the picture. (I'm not an advanced programmer so my code may not be 100% efficient - sorry, I'm still...
3
1280
by: Nathan Sokalski | last post by:
I am using ASP.NET, VB.NET, and GDI+ to dynamically create images for webpages. When I right-click on the dynamically created image to try to save it to my hard drive, which I send as ImageFormat.Gif, my browser (Internet Explorer 6.0) wants me to save it as a *.bmp file. The VB.NET line of code that I use to send the image to the browser is:...
6
6432
by: Mark Denardo | last post by:
My question is similar to one someone posted a few months back, but I don't see any replies. Basically I want to be able to have users upload photos and save them in a database (as byte data) and be able to load them to an image webcontrol, but system.web.ui.webcontrols.image only seems to have a control to load the image from a URL. ...
0
7406
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7660
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
5976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5337
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3457
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1888
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
709
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.