【发布时间】:2021-12-27 20:40:08
【问题描述】:
我正在尝试使用 MagicImage 将 HEIC 转换为 JPEG,因此我的 newFile.Data 包含发送到服务器的图像的字节 []。所以我很确定我的代码是正确的,但是当我将图像发送到服务器(即网络)时,它会以 HEIC 格式上传,但我需要它的 jpeg 格式。所以我被困在这里,无法弄清楚我需要做什么
using (var image = new MagickImage(newFile.Data))
{
// Sets the output format to jpeg
image.Format = MagickFormat.Jpeg;
// Create byte array that contains a jpeg file
byte[] data = image.ToByteArray();
}
var currentFiles =
_clientFileService.Value.GetFilesByClient(clientId).Where(x => x.ClientFileType == type).Select(x => x.Id).ToList();
_clientFileService.Value.MultipleDelete(currentFiles, null);
_clientFileService
.Value
.AddFile(
new ClientFile
{
Data = newFile.Data, // How can I pass MagickImage to newFile.Data
Guid = Guid.NewGuid()
});
【问题讨论】:
标签: c# imagemagick