public static async Task <GenerationReturn> CopyCleanResizeImage(ImageContent dbEntry, IProgress <string> progress) { if (dbEntry == null) { return(await GenerationReturn.Error("Null Image 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($"Image {dbEntry.Title} has no Original File", dbEntry.ContentId)); } var imageDirectory = UserSettingsSingleton.CurrentSettings().LocalSiteImageContentDirectory(dbEntry); var syncCopyResults = await FileManagement.CheckImageFileIsInMediaAndContentDirectories(dbEntry, progress); if (!syncCopyResults.HasError) { return(syncCopyResults); } CleanDisplayAndSrcSetFilesInImageDirectory(dbEntry, true, progress); ResizeForDisplayAndSrcset(new FileInfo(Path.Combine(imageDirectory.FullName, dbEntry.OriginalFileName)), false, progress); return(await GenerationReturn.Success($"{dbEntry.Title} Copied, Cleaned, Resized", dbEntry.ContentId)); }
public static void ConfirmOrGenerateImageDirectoryAndPictures(ImageContent dbEntry, IProgress <string> progress) { FileManagement.CheckImageFileIsInMediaAndContentDirectories(dbEntry, progress).Wait(); var targetDirectory = UserSettingsSingleton.CurrentSettings().LocalSiteImageContentDirectory(dbEntry); var sourceImage = new FileInfo(Path.Combine(targetDirectory.FullName, dbEntry.OriginalFileName)); PictureResizing.ResizeForDisplayAndSrcset(sourceImage, false, null); }
public static async Task <List <FileInfo> > ResizeForDisplayAndSrcset(ImageContent dbEntry, bool overwriteExistingFiles, IProgress <string> progress) { await FileManagement.CheckImageFileIsInMediaAndContentDirectories(dbEntry, progress); var targetDirectory = UserSettingsSingleton.CurrentSettings().LocalSiteImageContentDirectory(dbEntry); var sourceImage = new FileInfo(Path.Combine(targetDirectory.FullName, dbEntry.OriginalFileName)); return(ResizeForDisplayAndSrcset(sourceImage, overwriteExistingFiles, progress)); }