I am trying to convert a TIFF file to JPEG using FreeImage.
The problem is that FreeIamge.SaveToStream
doesn't actually do anything. Even after the call, stream
has a Length
, Capacity
and Position
of 0.
This is my code:
using (var stream = new MemoryStream())
{
var image = FreeImage.LoadEx(fileName);
FreeImage.SaveToStream(image, stream, FREE_IMAGE_FORMAT.FIF_JPEG,
FREE_IMAGE_SAVE_FLAGS.JPEG_QUALITYSUPERB);
// stream.Length, stream.Capacity & stream.Position are all 0 here
}
What am I doing wrong?
The problem was the input - a 16 bit image created by another image library. It looks like FreeImage has some problems with 16 bit images as GDI+ could read it without problems. I switched the input to a 24 bit image and the code in my question started working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With