diff --git a/src/Gifitti/Gifitti/Models/GifModel.cs b/src/Gifitti/Gifitti/Models/GifModel.cs index 8ae9d4732b6c02b21228261312b11b1e66655bd5..7497260d60d7559e159947233f85e1b168dbfcc9 100644 --- a/src/Gifitti/Gifitti/Models/GifModel.cs +++ b/src/Gifitti/Gifitti/Models/GifModel.cs @@ -70,17 +70,23 @@ namespace Gifitti.Models public void saveGif(string path) { //Error Handel on path - Regex savePathTest = new Regex(@"^(([^\/\\]+)[\/\\])*([^\/\\]*)\.[g|G][i|I][f|F]$"); - if (!savePathTest.IsMatch(path)) + + //RE for path with extension + Regex extensionTester = new Regex(@"^.*\.[g|G][i|I][f|F]$"); + //RE for path without extension + Regex savePathTester = new Regex(@"^(([^\/\\]+)[\/\\])*([^\/\\]*)"); + if (!savePathTester.IsMatch(path)) { throw new DirectoryNotFoundException(); } - + //Handel non gif extensions + if (!extensionTester.IsMatch(path)) + path += ".gif"; //TODO take in image setting components as well as frames being viewed etc. //Build GIF using (MagickImageCollection collection = new MagickImageCollection()) { - for (int i = 0; i < frames.Length; i++) + for (int i = this.startFrame; i < Math.Min(this.endFrame, frames.Length); i++) collection.Add(new MagickImage(frames[i] as Bitmap)); // Maximize Colour saturation