This project has moved. For the latest updates, please go here.

FileSize zero after Blur and ReduceNoise

Jan 26 at 7:22 PM
Doing some discovery work. Querying FileSize for an image, receiving expected size. Then calling Blur (or ReduceNoise) for the image, and again query FileSize. Always receiving zero for FileSize after the Blur or ReduceNoise. Expected?

How can I query for the file size to get the current size of the image after the action?

Thank you.
Jan 26 at 7:43 PM
The FileSize property is only there to get the original file size. You will need to save the image to get the new file size.
Mar 15 at 2:01 PM
Is ToByteArray "expensive"?

What we really care about for the application is the size in bytes, and candidate code for that is ToByteArray().Length.
        if (resizeParameters.SizeMaximumBytes.HasValue && (imageWrapper.ToByteArray().Length > resizeParameters.SizeMaximumBytes.Value))
            imageWrapper.Morphology(MorphologyMethod.Dilate, Kernel.Diamond);
            if (imageWrapper.ToByteArray().Length > resizeParameters.SizeMaximumBytes.Value)
                imageWrapper.BlurAndThreshold(0, 2, 50);
Curious about any performance or side effects from multiple calls on ToByteArray.
Does ToByteArray "do real work" such as processing image bytes, or does it simply convert the image structure to bytes?
Mar 16 at 12:40 AM
ToByteArray encodes the image and returns the bytes. You should not do this multiple times without changing the image. You could call the method like you do now but preserve the result and write that to a file with File.WriteAllBytes.