I have a code like this:
using (var image = Image.FromFile(imagePath))
{
image.Save(Path.ChangeExtension(imagePath, "jpg"), ImageFormat.Jpeg);
}
This converts the given image file into different format and saves it onto the HDD.
How can I convert the image into JPG, but instead of saving it, I want to put it into a byte[] variable. Something like:
byte[] img = image.ByteArray(Path.ChangeExtension(imagePath, "jpg"), ImageFormat.Jpeg);
Is this possible to do, without saving the image onto the HDD first and then loading it into byte array from a file?