【发布时间】:2012-02-16 18:15:27
【问题描述】:
例如,这里是示例 JPEG,我无法保存(!)但可以使用标准 dotnet 类读取(例如找出宽度和高度)。原始文件:
http://dl.dropbox.com/u/5079317/184809_1_original.jpg
在 Windows 图像编辑器中保存相同的图像后,一切正常: http://dl.dropbox.com/u/5079317/184809_1_resaved.jpg
我很久以前就注意到了这个错误,但这不是主要问题。但是在当前的项目中,我有数千张这样的图像,我真的需要某种解决方案。
可以使用哪些第三方库?
这是我的阅读方式:
public ImageFile SaveImage(HttpPostedFileBase file, string fileNameWithPath, bool splitImage, out string errorMessage)
{
try
{
using (var stream = file.InputStream)
{
using (Image source = Image.FromStream(stream))
{
return SaveImage(source, fileNameWithPath, splitImage, out errorMessage);
// which actually do source.Save(fileNameWithPath, ImageFormat.Jpeg);
// Exception: A generic error occurred in GDI+.
}
}
}
catch (Exception e)
...
}
【问题讨论】: