我正在尝试在我的mvc 4中使用image resizer.ImageJob来裁剪和保存图像,因为它正在上传。这是我的代码。
`//create cropping point information using the nameValueCollections specified in the image;
System.Drawing.PointF point1 = new SD.PointF(collectionsValues["x1Cords"], collectionsValues["y1Cords"]);
System.Drawing.PointF point2 = new SD.PointF(collectionsValues["x2Cords"], collectionsValues["y2Cords"]);
//Setup the resize settings
var resizeSettings = new ResizeSettings();
resizeSettings.CropXUnits = collectionsValues["widthOfSelection"];
resizeSettings.CropYUnits = collectionsValues["heightOfSelection"];
resizeSettings.Format = file.ContentType;
resizeSettings.CropTopLeft = point1;
resizeSettings.CropBottomRight = point2;
resizeSettings.Mode = FitMode.Crop;
//construct the image and save it in the disk.
ImageJob theProcessedImage = new ImageJob(file, imagePath, resizeSettings, true, false);
theProcessedImage.CreateParentDirectory = true;
theProcessedImage.Build();
`
我的问题是我不断获得异常以指定用于处理图像的编码器。每当调用 theProcessedImage.Build()时。那么如何指定编码器,我已按照我在imageresizing网站上找到的说明安装了 nuget(Install-Package ImageResizer.Plugins.Wic)包
答案 0 :(得分:0)
jpeg
,png
,gif
和webp
是目前唯一有效的输出格式。如果它要求解码器而不是编码器,则可能不支持源文件类型,或者您没有安装FreeImageDecoder plugin。