Essential DocIO没有用于更改图像格式的直接API。自系统。图形命名空间在ASP中不可用。NET核心平台,您需要使用任何一种可选的图像处理库(如中所述)
MSDN
)更改图片的图像格式。
下面的示例代码使用CoreCompat helper库更改图像格式:
WPicture picture = item as WPicture;
//Load the DocIO WPicture image bytes into CoreCompat Image instance.
Image image = Image.FromStream(new MemoryStream(picture.ImageBytes));
//Check image format, if format is other than png then convert the image as png format.
if (!image.RawFormat.Equals(ImageFormat.Png))
{
MemoryStream imageStream = new MemoryStream();
image.Save(imageStream, ImageFormat.Png);
//Load the png format image into DocIO WPicture instance.
picture.LoadImage(imageStream);
imageStream.Dispose();
}
//Resize the picture width and height.
picture.Width = 400;
picture.Height = 400;