public static async void BeforeAfterAnim(bool save, bool h264) { string ext = "gif"; if (h264) { ext = "mp4"; } DialogForm dialogForm = new DialogForm("Creating comparison " + ext.ToUpper() + "..."); string tempPath = Path.Combine(IOUtils.GetAppDataDir(), "giftemp"); string framesPath = Path.Combine(tempPath, "frames"); IOUtils.ClearDir(tempPath); Directory.CreateDirectory(framesPath); resultPreview = (Bitmap)ImgUtils.GetImage(Directory.GetFiles(IO.Paths.previewOutPath, "*.png.*", SearchOption.AllDirectories)[0]); Image image1 = originalPreview; Image image2 = resultPreview; if (Config.GetInt("comparisonUseScaling") == 1) { image1 = (Bitmap)ImgUtils.GetImage(Path.Combine(IO.Paths.previewPath, "preview.png.png")); } float scale = (float)image2.Width / (float)image1.Width; Logger.Log("Scale for animation: " + scale); string outpath = Path.Combine(tempPath, "comparison." + ext); if (image2.Width <= 2048 && image2.Height <= 2048) { image1.Scale(scale, InterpolationMode.NearestNeighbor).Save(Path.Combine(framesPath, "0.png")); image2.Save(Path.Combine(framesPath, "1.png")); if (h264) { await FFmpegCommands.FramesToOneFpsMp4(framesPath, false, 14, 9, "", false); File.Move(Path.Combine(tempPath, "frames." + ext), outpath); } else { await FFmpeg.RunGifski(" -r 1 -W 2048 -q -o " + outpath.Wrap() + " \"" + framesPath + "/\"*.\"png\""); } if (save) { string comparisonSavePath = Path.ChangeExtension(Program.lastImgPath, null) + "-comparison." + ext; File.Copy(outpath, comparisonSavePath, true); dialogForm.Close(); Program.ShowMessage("Saved current comparison to:\n\n" + comparisonSavePath, "Message"); } else { StringCollection paths = new StringCollection(); paths.Add(outpath); Clipboard.SetFileDropList(paths); dialogForm.Close(); Program.ShowMessage("The " + ext.ToUpper() + " file has been copied. You can paste it into any folder.\n" + "Please note that pasting it into Discord or other programs won't work as the clipboard can't hold animated images.", "Message"); } } else { Program.ShowMessage("The preview is too large for making an animation. Please create a smaller cutout or choose a different comparison type.", "Error"); } dialogForm.Close(); }