views:

42

answers:

1

I'm doing a conversion from .jpg to .png in System.Drawing and one thing that I've found is that this conversion tends to make the resulting converted .png much larger than the .jpg original. Sometimes more than 10x larger after converting to .png.

Given that seems to always be the case (unless you know of a way around this), is there any way to determine the file size of that .png before it is saved to disk? For example, maybe write it to a stream first and then get that stream size? How would I go about doing this?

+1  A: 

You can write to a MemoryStream and calculate the size of it, then write it to the FileSystem.

Although: There might be a better way.

Meiscooldude
How would I calculate the size of a MemoryStream?
Otaku
If you convert the JPG into the MemoryStream, the "Position" property should tell you your location within the steam (and thus, the size).
Patrick Steele