Reading LARGE image files for web output

B

Brad

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
 
P

Peter Huang

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.
 
P

Peter Huang

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.
 

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

Top