private void FaceImagePublishCreateEvent(object sender, ContentEventArgs e) { ContentData content = e.Content as ContentData; SaveContentEventArgs savingEvent = e as SaveContentEventArgs; if ((savingEvent.Action & EPiServer.DataAccess.SaveAction.CheckOut) != EPiServer.DataAccess.SaveAction.Default || content == null || ContentReference.IsNullOrEmpty(e.ContentLink)) { return; } Dictionary <string, EPiFaceImageAttribute> faceImageProperties = ListFaceImageProperties(e); if (faceImageProperties.Count == 0) { return; } ContentAssetFolder contentAssetFolder = _contentAssetHelperInj.Service.GetOrCreateAssetFolder(e.ContentLink); if (contentAssetFolder == null) { return; } foreach (var faceImagePropertyDef in faceImageProperties) { ContentReference imageReference = content.GetPropertyValue <ContentReference>(faceImagePropertyDef.Key); if (ContentReference.IsNullOrEmpty(imageReference)) { continue; } ImageData image; if (!_contentLoaderInj.Service.TryGet(imageReference, out image) || image.GetOriginalType() == typeof(FaceImageData) || image.BinaryData == null) { continue; } Image imageDetails = Image.FromStream(new MemoryStream(image.BinaryData.ReadAllBytes())); if (imageDetails == null) { continue; } byte[] faceResizedImage; if (!TryToDetectFaceAndResizeImage(faceImagePropertyDef, image, imageDetails, out faceResizedImage)) { continue; } ContentReference faceImageId = CreateFaceMediaFile(contentAssetFolder, image, faceResizedImage); content[faceImagePropertyDef.Key] = faceImageId; } }