如何在ImageResizer中使用autorotate插件
如何在ac#console应用程序中使用AutoRotate插件? 我以为我能做类似settings.AutoRotate = true;
事情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); }
经过大量的研究,我发现了我正在制作的错误,并揭示了.Net的一个不错的“隐藏function”!
当图像被读入Bitmap对象时,元数据被擦除,因此,通过接受Image对象,关于方向的数据将丢失并且自动旋转不会启动。因此,传递图像文件名而不是图像对象,我上面的代码工作!
多谢你们!