如何自动旋转上传的图像

时间:2015-07-17 23:44:56

标签: c# autorotate imageresizer

我有一个网站,我允许用户上传照片。这些文件以HttpPostedFile的形式上载到我的WebAPI端点。在上传的文件上执行一些验证后,我得到了流:

var stream = httpPostedFile.InputStream;

然后调整大小:

        var instructions= new Instructions
        {
            Width = 80, Height = 80,
            OutputFormat = OutputFormat.Jpeg,
            Mode = FitMode.Crop,
            AutoRotate = true
        };

        var smallResizedImage = new MemoryStream();
        var imageJob = new ImageJob(stream, smallResizedImage, instructions);
        imageJob.Build();

请注意在说明中我指定应该旋转图像。但是我的图像不会旋转,但会正确调整大小。

我甚至尝试过设置密钥,但我得到了相同的结果:

instructions.Add("autorotate", "true");

我使用的是ImageResizer版本3.4.3,没有任何额外的插件或更改配置设置。

基于Nathanael Jones的previous comment,我不会将我的信息流复制到位图或图像中,因此我不认为EXIF信息正在删除。

0 个答案:

没有答案