views:

457

answers:

3

We have a WebService with a method to upload images, this method accepts a byte array which is a TIFF.

On the client side the TIFF is loaded with Image.FromFile(path) and then saved into a MemoryStream. Then memoryStream.ToArray() is called which results in a byte array which is used in the WebService request.

Currently we have a TIFF which is 130 KB big, but the total request size is almost 10 MB. How can this happen? Is this because the Image.FromFile method converts (deflates) the TIFF to a standard format, so compression etc is lost? Is there a better way of doing this?

Thanks.

+2  A: 

Loading the tiff into an Image does remove all of the compression of the TIFF.

If you don't really have a need to load it into the Image, I'd just read it into memory as an arbitrary file and send the byte array that way.

Moose
I'll give that a try, thanks.
Gerrie Schenck
+1  A: 

I haven't verified that what you're suggesting (that Image is decompressing the tiff into a much bigger file) is actually happening, though it seems likely. But, if that's the case, then couldn't you just read in the file not as an Image, but as a binary?

Just read in the file as though it was a binary file, and drop that into the memoryStream. Then there shouldn't be any problem with decompression.

Beska
+1  A: 

Maybe you can use WSE 3.0 MTOM, witch is the best way to sent images through web services

You can find more info here

freggel