Mar*_*les 5 c# autorotate imageresizer
如何在ac#console应用程序中使用AutoRotate插件?我以为我能做的事情就像settings.AutoRotate = true;我可以改变合身模式来使用接缝雕刻插件.
我已经尝试settings.Add("autorotate","true")过keycollection,以及其他键名AutoRotate和autoRotate.
我在一个简单的方法中使用它.
new AutoRotate().Install(ImageResizer.Configuration.Config.Current);
...
protected static Image ResizeImage(Image image, double scaleFactor)
{
var settings = new ResizeSettings
{
Scale = ScaleMode.Both,
Width = (int)Math.Floor(Image.Width * scaleFactor),
Height = (int)Math.Floor(Image.Height * scaleFactor),
Mode = FitMode.None,
Format = "png"
};
settings.Set("autorotate", "true");
return ImageBuilder.Current.Build(image, settings, true);
}
Run Code Online (Sandbox Code Playgroud)
经过大量的研究,我发现了我正在制作的错误,并揭示了.Net的一个不错的"隐藏功能"!
当图像被读入Bitmap对象时,元数据被擦除,因此,通过接受Image对象,有关方向的数据将丢失,并且自动旋转不会启动.因此,传递图像文件名而不是图像对象,我上面的代码工作!
多谢你们!