我在我的事件系统中使用以下代码来上传svg图像。但是在保存图像时,这会给出“参数无效错误”。以下是我正在使用的代码。有什么我想念的吗?任何帮助将非常感激。提前谢谢。
//only for imagaes: svg
if (mimeType.Contains("svg") && !String.IsNullOrEmpty(filename))
{
messageLog.WriteEntry("OnComponentSavePre - resizing image - for component: " + comp.Title);
// need to save first new component to be able to get type in next step
if (args.IsNewItem)
{
comp.Save();
}
BinaryContent bc = comp.BinaryContent;
var objConvertor = System.ComponentModel.TypeDescriptor.GetConverter(typeof(System.Drawing.Bitmap));
var bmpObj = (Bitmap)objConvertor.ConvertFrom(bc.GetByteArray());
//reades multimedia fields
ItemFields itemFields = new ItemFields(comp.Metadata, comp.MetadataSchema);
if (itemFields.Contains("MM_Width"))
{
NumberField width = itemFields["MM_Width"] as NumberField;
if (width != null && width.Value <= 0)
{
messageLog.WriteEntry("width = " + width.Value, EventLogEntryType.Information, 0, 0);
width.Value = bmpObj.Width;
}
}
if (itemFields.Contains("MM_Height"))
{
NumberField height = itemFields["MM_Height"] as NumberField;
if (height != null && height.Value <= 0)
{
messageLog.WriteEntry("width = " + height.Value, EventLogEntryType.Information, 0, 0);
height.Value = bmpObj.Height;
}
}
comp.Metadata = itemFields.ToXml();
messageLog.WriteEntry("metadata updated", EventLogEntryType.Information, 0, 0);
}