如何在ImageResizer中使用autorotate插件

时间:2013-09-09 14:34:11

标签: c# autorotate imageresizer

如何在c#控制台应用程序中使用AutoRotate插件?我以为我能够像settings.AutoRotate = true;这样做,就像我可以改变合身模式来使用接缝雕刻插件。

我已经尝试了settings.Add("autorotate","true")来进行密钥收集,以及其他关键名AutoRotateautoRotate

我在一个简单的方法中使用它。

    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);
    }

1 个答案:

答案 0 :(得分:5)

经过大量的研究,我发现了我正在制作的错误,并揭示了.Net的一个不错的“隐藏功能”!

当图像被读入Bitmap对象时,元数据被删除,因此,通过接受Image对象,有关方向的数据将丢失,并且自动旋转不会启动。因此,传递图像文件名图像对象,我上面的代码工作!

谢谢你们!