C# 在c中上载时,从图像中删除Exif数据的最佳方法是什么#
在c#中上载时,从图像中删除Exif数据的最佳方法是什么? 我尝试了以下给出的解决方案: 但我面临的问题是,在保存来自上述解决方案的输出流后,图像不可读。 它从文件中删除Exif信息。但我以后无法查看图像 有人能帮我吗 下面是我的代码:C# 在c中上载时,从图像中删除Exif数据的最佳方法是什么#,c#,asp.net,file-upload,exif,C#,Asp.net,File Upload,Exif,在c#中上载时,从图像中删除Exif数据的最佳方法是什么? 我尝试了以下给出的解决方案: 但我面临的问题是,在保存来自上述解决方案的输出流后,图像不可读。 它从文件中删除Exif信息。但我以后无法查看图像 有人能帮我吗 下面是我的代码: protected void SaveFile() { try { JpegPatcher _jpegPatcher = new JpegPatcher(); Sy
protected void SaveFile()
{
try
{
JpegPatcher _jpegPatcher = new JpegPatcher();
System.IO.Stream stream = new System.IO.MemoryStream();
//Get stream data of uploaded file
Stream checkStream = fileUpload.PostedFile.InputStream;
//Pass the stream to remove Exif info
Stream outStream1 = _jpegPatcher.PatchAwayExif(checkStream, stream);
//Save the file
string Fpath = Path.Combine(path, fileUpload.FileName);
using (FileStream outputFileStream = new FileStream(Fpath, FileMode.Create, FileAccess.Write))
{
stream.Position = 0;
stream.CopyTo(outputFileStream);
stream.Flush();
}
}
catch (Exception ex)
{
throw ex;
}
}
这是否有帮助,并简化。请记住,在开始读取时,确保输入流上的位置为0
JpegPatcher _jpegPatcher = new JpegPatcher();
//Get stream data of uploaded file
Stream checkStream = fileUpload.PostedFile.InputStream;
checkStream.Position = 0; // Reset position
//Pass the stream to remove Exif info
//Save the file
string Fpath = Path.Combine(path, fileUpload.FileName);
using (FileStream outputFileStream = new FileStream(Fpath, FileMode.Create, FileAccess.Write))
{
_jpegPatcher.PatchAwayExif(checkStream, outputFileStream);
}