Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure webjob映像大小调整问题_Azure_Azure Webjobs - Fatal编程技术网

Azure webjob映像大小调整问题

Azure webjob映像大小调整问题,azure,azure-webjobs,Azure,Azure Webjobs,我正在使用azure web作业保存图像的拇指,这是用于执行此操作的代码 ImageProcessor.Imaging.Formats.FormatBase f; f = new ImageProcessor.Imaging.Formats.JpegFormat(); Size size = new Size(200, 200); using (WebClient client = new WebClient()) { MemoryS

我正在使用azure web作业保存图像的拇指,这是用于执行此操作的代码

ImageProcessor.Imaging.Formats.FormatBase f;
f = new ImageProcessor.Imaging.Formats.JpegFormat();


Size size = new Size(200, 200); 
using (WebClient client = new WebClient())
            {
                MemoryStream stream = new MemoryStream(client.DownloadData(input));
                MemoryStream stream2 = new MemoryStream();
                int quality = 110;


                do
                {
                    quality = quality - 10;
                    using (ImageFactory factory = new ImageFactory(false))
                    {
                        factory.Load(stream)
                            .Format(f)
                            .Resize(size)                          
                            //.BackgroundColor(Color.White)
                            .Quality(quality)
                            .Save(stream2);
                    }
                } while (stream2.Length > stream.Length || stream2.Length ==100000);
例如,当我使用图像将消息添加到队列时, 工作应该给我的拇指图像200*200,但有尾随黑色区域在顶部和底部的结果图像像不应该这样做
为什么要这样做?

您正在尝试将矩形拟合成正方形

发件人:

调整大小 将当前图像调整为给定尺寸。如果要保留EXIF元数据,其中包含的信息也将更新以匹配

公共图像工厂调整大小(大小)

参数

尺寸:

包含要设置图像的宽度和高度的
系统.Drawing.Size

为任一维度传递0将忽略该维度。

因此,传入
0
作为高度以保持纵横比

Size Size Size=新的大小(200,0);

或者使用其他调整大小模式之一:Crop/Min/Max/Stretch

可能是源图像不是方形的,但您试图将其调整为方形尺寸,并且函数试图保持原始纵横比?您的图像是500x375。不确定在没有任何类型的条形图的情况下如何正确生成200x200缩略图。在任何情况下:这不是一个数据库问题(而且似乎也不是一个编程问题)。@DavidMakogon sorry header是由mistake@DavidMakogon酒吧是什么意思???@Moustafa我指的是你提到的“黑色区域”。或黑条,通常指的是黑条。非常感谢您的详细回答:)