如何使用ImageResizer自动旋转插件 [英] How to use the autorotate plugin in ImageResizer

查看:346
本文介绍了如何使用ImageResizer自动旋转插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用自动旋转插件在C#控制台应用程序?我想我能做到像 settings.AutoRotate = TRUE; 就像我可以改变的配合模式使用接缝焊接插件



我试过 settings.Add(自动旋转,真)来的keycollection,以及其他键名自动旋转自动旋转



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

 新自动旋转()安装(ImageResizer.Configuration.Config.Current); 
...
受保护的静态图像ResizeImage(形象画像,双比例因子)
{
VAR设置=新ResizeSet​​tings
{
标尺= ScaleMode.Both ,
宽度=(int)的Math.Floor(Image.Width *比例因子),
高度=(int)的Math.Floor(Image.Height *比例因子),
模式= FitMode.None ,
格式=PNG
};

settings.Set(自动旋转,真);
返回ImageBuilder.Current.Build(图像,设置,真实);
}


解决方案

大量的研究后,我发现,我做了错误,并揭示的.Net的一个可爱的小隐藏功能!



当图像被读入位图对象,元数据被删除,所以,通过接受一个I​​mage对象,对定向数据丢失,自动旋转不踢。所以,通过图像文件名,而不是图像对象,而我上面的代码上面的作品!



谢谢你们!


How do I use the AutoRotate plugin in a c# console application? I thought I'd be able to do something like settings.AutoRotate = true; like I can change the fit mode to use the seam carving plugin.

I've tried settings.Add("autorotate","true") to the keycollection, as well as other keynames AutoRotate and autoRotate.

I'm using it in a simple method.

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

解决方案

After a lot of research, I've found the error that I'm making, and reveals a nice little "hidden feature" of .Net!

When an image is read into the Bitmap object, the meta data is erased, so, by accepting an Image object, the data about the orientation is lost and auto rotate doesn't kick in. So, passing the image filename instead of the image object, and my code above above works!

Thanks guys!

这篇关于如何使用ImageResizer自动旋转插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆