/// <summary> /// </summary> /// <param name="dbEntry"></param> /// <param name="progress"></param> /// <returns></returns> public static async Task <GenerationReturn> CopyCleanResizePhoto(PhotoContent dbEntry, IProgress <string> progress) { if (dbEntry == null) { return(await GenerationReturn.Error("Null Photo Content submitted to Copy Clean and Resize")); } progress?.Report($"Starting Copy, Clean and Resize for {dbEntry.Title}"); if (string.IsNullOrWhiteSpace(dbEntry.OriginalFileName)) { return(await GenerationReturn.Error($"Photo {dbEntry.Title} has no Original File", dbEntry.ContentId)); } var photoDirectory = UserSettingsSingleton.CurrentSettings().LocalSitePhotoContentDirectory(dbEntry); var syncCopyResults = await FileManagement.CheckPhotoFileIsInMediaAndContentDirectories(dbEntry, progress); if (!syncCopyResults.HasError) { return(syncCopyResults); } CleanDisplayAndSrcSetFilesInPhotoDirectory(dbEntry, true, progress); ResizeForDisplayAndSrcset(new FileInfo(Path.Combine(photoDirectory.FullName, dbEntry.OriginalFileName)), false, progress); return(await GenerationReturn.Success($"{dbEntry.Title} Copied, Cleaned, Resized", dbEntry.ContentId)); }
public static void ConfirmOrGeneratePhotoDirectoryAndPictures(PhotoContent dbEntry, IProgress <string> progress) { FileManagement.CheckPhotoFileIsInMediaAndContentDirectories(dbEntry, progress).Wait(); var targetDirectory = UserSettingsSingleton.CurrentSettings().LocalSitePhotoContentDirectory(dbEntry); var sourceImage = new FileInfo(Path.Combine(targetDirectory.FullName, dbEntry.OriginalFileName)); PictureResizing.ResizeForDisplayAndSrcset(sourceImage, false, null); }
public static async Task <List <FileInfo> > ResizeForDisplayAndSrcset(PhotoContent dbEntry, bool overwriteExistingFiles, IProgress <string> progress) { await FileManagement.CheckPhotoFileIsInMediaAndContentDirectories(dbEntry, progress); var targetDirectory = UserSettingsSingleton.CurrentSettings().LocalSitePhotoContentDirectory(dbEntry); var sourceImage = new FileInfo(Path.Combine(targetDirectory.FullName, dbEntry.OriginalFileName)); return(ResizeForDisplayAndSrcset(sourceImage, overwriteExistingFiles, progress)); }