static void Main(string[] args) { try { CommandLineArgs cmdLine = new CommandLineArgs(args); using (NpkReader npk = LoadNpk(cmdLine.NpkPath)) { NpkPath imgPath = GetImgPath(cmdLine, npk); RawAnimation animationData = new RawAnimation(); animationData.Loop = true; List<ConstAnimationFrame> frameInfo = GetFrameInfo(cmdLine, npk, imgPath); animationData.Frames = frameInfo; CreateOutputDir(cmdLine.OutputPath); using (FileStream gifOutputStream = OpenOutput(cmdLine.OutputPath)) using (GifMaker giffer = new GifMaker(npk, disposeImageSource: false)) { try { giffer.Create(animationData.AsConst(), gifOutputStream); } catch (Exception ex) { Console.Error.WriteLine("Error creating GIF: {0}", Utils.GetExceptionMessageWithInnerExceptions(ex)); Console.Error.WriteLine(ex.StackTrace); giffer.Dispose(); gifOutputStream.Dispose(); npk.Dispose(); Environment.Exit(1); } } } Console.WriteLine("GIF saved to {0}", cmdLine.OutputPath); } catch (OptionException ex) { Console.Error.WriteLine(ex.Message); Console.Error.WriteLine("Run with -h for help"); } catch (Exception ex) { Console.Error.WriteLine("Unexpected error: {0}", Utils.GetExceptionMessageWithInnerExceptions(ex)); Console.Error.WriteLine(ex.StackTrace); } }