问题
How can I convert an image to array of bytes using ImageSharp library?
Can ImageSharp library also suggest/provide RotateMode and FlipMode based on EXIF Orientation?
回答1:
If you are looking to convert the raw pixels into a byte[]
you do the following.
var bytes = image.SavePixelData()
If you are looking to convert the encoded stream as a byte[]
(which I suspect is what you are looking for). You do this.
using (var ms = new MemoryStream())
{
image.Save(ms, imageFormat);
return ms.ToArray();
}
回答2:
Onto the second question: There's a transformation API function called AutoOrient()
. Look it up ;)
来源:https://stackoverflow.com/questions/50025908/convert-imagergba32-to-byte-using-imagesharp