By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,313 Members | 1,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,313 IT Pros & Developers. It's quick & easy.

Reading LARGE image files for web output

P: n/a
I'm working on a web app which will display LARGE tiff image files (e.g
files 10-20+ mb). Files are hidden from users direct access. For other,
smaller image files I have used FileStream to read in a file in a single
Read and so my quesitons are:

(1) What is a practical file size limit for reading using FileStream.Read
(reading the file in a single read)...especially on a web server where I
don't think I'd want to tax memory resources by to many simultaneous large
file reads?
(2) For a file larger than the practical size limit what's the best means
to read the file in chunks? Streams are not my forte so any code samples
are appreciated if applicable.

Here iss code I've used for a single read using FileStream. Seem to work
fine with large tiff but again the concern is resources (memory) on a
produciton web.

Dim fs As FileStream = New FileStream(outputFile,
FileMode.Open)
Try
Dim bufferSize As Integer = CType(fs.Length,
Integer)
Dim buffer(bufferSize) As Byte
fs.Read(buffer, 0, bufferSize)
Current.Response.BinaryWrite(buffer)
Catch ex As Exception
Finally
fs.Close()
End Try

Thanks
- Brad
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Brad,

I think there is no limitation for the FileStream.Read operation except
that what is the CPU speed, disk IO spead, memory and so on physical
hardware limitation.

Can you tell me what on earth do you want to do?
e.g. I think if you wants to display the image, you may use the image
thumb, and also once you have read the image into memory, you can cache the
image, so that other thread will not to re-read the image from disk.(surely
a big cache will consume a lot of RAM).

You should try to balance the speed and the memory space. The more cache
you use, the faster you code will run, but the more memory you will use.

If if you do not wants to block the current reading thread, you may try to
use the BeginRead(asynchronous method) which will run the read operation on
another thread so the main thread will not be block.

Hope this helps.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2

P: n/a
Hi

If you still have any concern on this issue, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #3

P: n/a
Hi

If you still have any concern on this issue, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.