473,786 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

writing image to disk

Hey all,
I'm hoping someone can help me with a little problem I have.
First a little background. I'm working on developing a site which
displays live feeds from a security camera. The camera is connected to
our network via a network video server. Now here's the problem.
One of the requirements of this particular project is that the user be
able to save a snapshot of the live video feed at any given time and
save it to disk. Now, the network video server provides a method for
generating snapshots. The problem I have is getting the page to save
the snapshot automatically.

The address of the image actually works out to be something like
"http://www.site.com:97/images1sif?rand om=4325623"

The port is specified in the address because that is how the network
camera server is referenced by our routers.

I currently have a page set up that can display an image specified and
has a save button that the user can click to save the image (some of
our users aren't bright enough to right click and choose save as...).
The code I currently have is as follows:

sFileName = "Temp.jpg"
sFile = imgArchive.Imag eUrl
Response.ClearH eaders()
Response.ClearC ontent()
Response.Clear( )
Response.AddHea der("Content-Disposition","a ttachment;filen ame=" &
sFileName)
Response.Conten tType = "Image/JPG"
Response.WriteF ile(Server.MapP ath(sFile))

This code works fine when the image is stored on the server itself,
however the images I need to save are not stored on the server, they
are on the network video server as I stated before.

Also, I will need to occasionally save these images directly to our
server for other purposes.

Any help that can be provided is appreciated. If any other
clarification is needed, please let me know.

Nov 19 '05 #1
5 1781
First you need to retrieve the image file from the video server before you
can use Response.Writef ile (or a similar function) or save it to the server.
This can be done in .NET 1.x with the WebRequest object.
Here's more info on the WebRequest object.
http://msdn.microsoft.com/library/de...classtopic.asp

In VB2005 its even easier. It can be done with a single line of code:
My.Computer.Net work.DownloadFi le(address as string, destinationFile Name as
string)

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

<aa************ @hotmail.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Hey all,
I'm hoping someone can help me with a little problem I have.
First a little background. I'm working on developing a site which
displays live feeds from a security camera. The camera is connected to
our network via a network video server. Now here's the problem.
One of the requirements of this particular project is that the user be
able to save a snapshot of the live video feed at any given time and
save it to disk. Now, the network video server provides a method for
generating snapshots. The problem I have is getting the page to save
the snapshot automatically.

The address of the image actually works out to be something like
"http://www.site.com:97/images1sif?rand om=4325623"

The port is specified in the address because that is how the network
camera server is referenced by our routers.

I currently have a page set up that can display an image specified and
has a save button that the user can click to save the image (some of
our users aren't bright enough to right click and choose save as...).
The code I currently have is as follows:

sFileName = "Temp.jpg"
sFile = imgArchive.Imag eUrl
Response.ClearH eaders()
Response.ClearC ontent()
Response.Clear( )
Response.AddHea der("Content-Disposition","a ttachment;filen ame=" &
sFileName)
Response.Conten tType = "Image/JPG"
Response.WriteF ile(Server.MapP ath(sFile))

This code works fine when the image is stored on the server itself,
however the images I need to save are not stored on the server, they
are on the network video server as I stated before.

Also, I will need to occasionally save these images directly to our
server for other purposes.

Any help that can be provided is appreciated. If any other
clarification is needed, please let me know.

Nov 19 '05 #2
Thank you very much Steve. I will try this first thing in the morning
when I get back to the office.

Steve C. Orr [MVP, MCSD] wrote:
First you need to retrieve the image file from the video server before you
can use Response.Writef ile (or a similar function) or save it to the server.
This can be done in .NET 1.x with the WebRequest object.
Here's more info on the WebRequest object.
http://msdn.microsoft.com/library/de...classtopic.asp

In VB2005 its even easier. It can be done with a single line of code:
My.Computer.Net work.DownloadFi le(address as string, destinationFile Name as
string)

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


Nov 19 '05 #3
Steve,
Thanks again for the quick response. I do have a further question
though, and please bear in mind that I am brand new to asp.net.
While searching for solutions based off your suggestion, I came upon
the following code:
Sub Page_Load(Sende r As Object, E As EventArgs)
Dim sURL As String = "http://www.site.com:82/images1sif?rand om=12345
Dim SR2 = New
StreamReader(Sy stem.Net.WebReq uest.Create(sUR L).GetResponse( ).GetResponseSt ream(),System.T ext.Encoding.Un icode,True,1000 000)
System.Drawing. Image.FromStrea m(SR2.BaseStrea m).Save(Server. MapPath("../../Output/testing.gif"),S ystem.Drawing.I maging.ImageFor mat.GIF)
End Sub

Now, this code works perfectly fine if the image is in a directory on
our server (i.e. www.site.com/images/image.jpg) but it fails when I try
and specify our video server which is referenced by going to port 82.

When I try and do this I get the error "The underlying connection was
closed: Unable to connect to the remote server."

Is this a problem relating to the fact that I'm specifying a port
number? Or could it possibly be that the video server just isn't
responding to the request? Keep in mind that if I just go to
www.site.com:82?/images1sif?random=12345 the image comes up perfectly
fine.

Is there another way to go about what I'm trying to do? Possibly load
the image into a standard html <img> tag and then somehow save the
contents to disk?
Again, I'm new to asp.net so please forgive me if I'm missing something
obvious.

Thanks again
Aaron Douglas

Nov 19 '05 #4
By default the ASPNET user account does not have access to network
directories. Either grant it access or have ASP.NET run under a different
user account by using impersonation.

For example, you can add a line similar to this to your web.config file:
<identity impersonate="tr ue" userName="domai n\MyAppUser">
password="passw ord"/>

For testing purposes you can have it use your user account since you know
you have the necessary permissions to write to that network location.

Here's more info on impersonation:
http://msdn.microsoft.com/library/de...ersonation.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
<aa************ @hotmail.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
Steve,
Thanks again for the quick response. I do have a further question
though, and please bear in mind that I am brand new to asp.net.
While searching for solutions based off your suggestion, I came upon
the following code:
Sub Page_Load(Sende r As Object, E As EventArgs)
Dim sURL As String = "http://www.site.com:82/images1sif?rand om=12345
Dim SR2 = New
StreamReader(Sy stem.Net.WebReq uest.Create(sUR L).GetResponse( ).GetResponseSt ream(),System.T ext.Encoding.Un icode,True,1000 000)
System.Drawing. Image.FromStrea m(SR2.BaseStrea m).Save(Server. MapPath("../../Output/testing.gif"),S ystem.Drawing.I maging.ImageFor mat.GIF)
End Sub

Now, this code works perfectly fine if the image is in a directory on
our server (i.e. www.site.com/images/image.jpg) but it fails when I try
and specify our video server which is referenced by going to port 82.

When I try and do this I get the error "The underlying connection was
closed: Unable to connect to the remote server."

Is this a problem relating to the fact that I'm specifying a port
number? Or could it possibly be that the video server just isn't
responding to the request? Keep in mind that if I just go to
www.site.com:82?/images1sif?random=12345 the image comes up perfectly
fine.

Is there another way to go about what I'm trying to do? Possibly load
the image into a standard html <img> tag and then somehow save the
contents to disk?
Again, I'm new to asp.net so please forgive me if I'm missing something
obvious.

Thanks again
Aaron Douglas

Nov 19 '05 #5
I'm sorry, there's one thing I didn't necessarily make clear. The
network video server in this case is not actually another computer. It
is simply a stand alone device that is connected to the network, and
the security camera at the same time. This is a box that has very
limited capabilities. The only software it really has running on it is
a basic web server (I'm not even sure what kind) and whatever software
is needed to control the camera. There are no logins, or users to
really speak of.

Is there possibly another way to do this? As I stated, loading the
image into a image control works perfectly fine. Is there any way to
possibly user the system.drawing namespace to somehow save the image?

Nov 19 '05 #6

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

Similar topics

4
9059
by: Igor Shulgin | last post by:
Hi! What is standard and direct way (within Oracle 9.2 stored procedures) for writing binary data from Oracle to external file on disk? We have tried to use UTL_FILE package, but it operates on files consisting out of "line" of size no more than 32767 bytes and adds new_line symbol upon closing files. Also we checked out interMedia types and packages for writing BLOB to disk but now we get stuck with some strange error messages.
5
1932
by: Ben Jeurissen | last post by:
Hello, I have to deal with the following issue in C++: Two threads are started from the main thread, both capturing images from a different firewire camera. Both threads take shots of 460800 bytes at a rate of 30 frames per second. This works fine, without frame loss, and I can display the two framestreams on screen. Now I would like to write these frames to my disk too (2 10000rpm in
2
2363
by: Tim T | last post by:
Hi, Could someone please point to to a tutorial / code for dynamically resizing images on upload, THEN saving to disk on the webserver. I need users to be able to upload images to my server, but they will not be aware of optimising graphics for the web, if someone uploads a 300k 640x480 jpeg for example, i need to be able to shrink it down to a - say 400x300 65k file BEFORE saving to my webserver. I have been looking on the web and have...
7
11639
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an OpenFileDialog: Dim result As DialogResult = Pic_Sel.ShowDialog() If (result = DialogResult.OK) Then
9
8782
by: Tom John | last post by:
Hi I am storing images in an access database, based on an MSDN article. The code i use to store is as follows: <code> 'Create the command object Dim command As New OleDbCommand("ImageBlobUpdate", dataConnection) Command.CommandType = CommandType.StoredProcedure)
12
3767
by: Chris Springer | last post by:
I'd like to get some feedback on the issue of storing data out to disk and where to store it. I've never been in a production environment in programming so you'll have to bear with me... My question is about storing data in a database. Yes I understand that you can link to a database in your program and read and write to the database etc etc. Well, that's all find and dandy but what if the person you're writing the application for...
2
2519
by: Mark Denardo | last post by:
Hi, I need some expert GDI+ person to help me with my RoundOffImage Function: What I'm trying to do is take in an image, crop off the edges around an ellipse region I set up, and then return the cropped image from the function. I sort of have this working, but not thoroughly. If I take the output image of this function and draw it on my form it shows the clipped image as transparent as I am wanting it. But if I take that image and...
3
18962
by: nicolasg | last post by:
Hi, I'm trying to open a file (any file) in binary mode and save it inside a new text file. After that I want to read the source from the text file and save it back to the disk with its original form. The problem is tha the binary source that I extract from the text file seems to be diferent from the source I saved. Here is my code: 1) handle=file('image.gif','rb')
2
3233
by: bharathv6 | last post by:
i need to do is modify the image in memory like resizing the image in memory etc ... with out saving it disk as i have to return back the image with out saving it disk PIL supports the use of StringIO objects being passed in place of file objects. StringIO objects are binary strings of variable length that are kept in memory so i saved the image in stringio objects the following code does that file = StringIO() image.save(file, "JPEG") ...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4064
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
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.