diff --git a/src/ImageProcessor.Playground/Program.cs b/src/ImageProcessor.Playground/Program.cs index 6201c21c9..80193905f 100644 --- a/src/ImageProcessor.Playground/Program.cs +++ b/src/ImageProcessor.Playground/Program.cs @@ -66,7 +66,7 @@ namespace ImageProcessor.PlayGround { using (ImageFactory imageFactory = new ImageFactory(true)) { - Size size = new Size(200, 0); + Size size = new Size(270, 260); ResizeLayer layer = new ResizeLayer(size, ResizeMode.Max, AnchorPosition.Center, false); //ContentAwareResizeLayer layer = new ContentAwareResizeLayer(size) @@ -84,12 +84,12 @@ namespace ImageProcessor.PlayGround //.Format(new PngFormat()) //.BackgroundColor(Color.Cyan) //.ReplaceColor(Color.FromArgb(255, 1, 107, 165), Color.FromArgb(255, 1, 165, 13), 80) - //.Resize(layer) + .Resize(size) //.DetectEdges(new SobelEdgeFilter(), false) //.DetectEdges(new LaplacianOfGaussianEdgeFilter()) //.EntropyCrop() //.Filter(MatrixFilters.Invert) - .Filter(MatrixFilters.Comic) + //.Filter(MatrixFilters.Comic) //.Filter(MatrixFilters.HiSatch) //.Pixelate(8) //.GaussianSharpen(10) diff --git a/src/ImageProcessor.Playground/images/input/test-original.gif.REMOVED.git-id b/src/ImageProcessor.Playground/images/input/test-original.gif.REMOVED.git-id new file mode 100644 index 000000000..60122bcf6 --- /dev/null +++ b/src/ImageProcessor.Playground/images/input/test-original.gif.REMOVED.git-id @@ -0,0 +1 @@ +782fb5ca5bb57601d2533c090a3c56bc2abd2ae0 \ No newline at end of file diff --git a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs index b21eb58bb..adf927d04 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs @@ -134,7 +134,7 @@ namespace ImageProcessor.Imaging.Formats { int frameCount = image.GetFrameCount(FrameDimension.Time); int last = frameCount - 1; - int length = 0; + double length = 0; List gifFrames = new List(); @@ -145,8 +145,7 @@ namespace ImageProcessor.Imaging.Formats { // Convert each 4-byte chunk into an integer. // GDI returns a single array with all delays, while Mono returns a different array for each frame. - int delay = BitConverter.ToInt32(times, (4 * i) % times.Length); - delay = delay * 10 < 20 ? 20 : delay * 10; // Minimum delay is 20 ms + TimeSpan delay = TimeSpan.FromMilliseconds(BitConverter.ToInt32(times, (4 * i) % times.Length) * 10); // Find the frame image.SelectActiveFrame(FrameDimension.Time, i); @@ -160,7 +159,7 @@ namespace ImageProcessor.Imaging.Formats image.SelectActiveFrame(FrameDimension.Time, 0); } - length += delay; + length += delay.TotalMilliseconds; } info.GifFrames = gifFrames; diff --git a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs index 826ddf42f..b37b08a37 100644 --- a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs +++ b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs @@ -211,7 +211,7 @@ namespace ImageProcessor.Imaging.Formats this.WriteHeaderBlock(gifStream, frame.Image.Width, frame.Image.Height); } - this.WriteGraphicControlBlock(gifStream, frame.Delay); + this.WriteGraphicControlBlock(gifStream, Convert.ToInt32(frame.Delay.TotalMilliseconds / 10F)); this.WriteImageBlock(gifStream, !this.isFirstImage, frame.X, frame.Y, frame.Image.Width, frame.Image.Height); } @@ -351,7 +351,7 @@ namespace ImageProcessor.Imaging.Formats this.WriteShort(GraphicControlExtensionBlockIdentifier); // Identifier this.WriteByte(GraphicControlExtensionBlockSize); // Block Size this.WriteByte(blockhead[3] & 0xf7 | 0x08); // Setting disposal flag - this.WriteShort(Convert.ToInt32(frameDelay / 10.0f)); // Setting frame delay + this.WriteShort(frameDelay); // Setting frame delay this.WriteByte(blockhead[6]); // Transparent color index this.WriteByte(0); // Terminator } diff --git a/src/ImageProcessor/Imaging/Formats/GifFrame.cs b/src/ImageProcessor/Imaging/Formats/GifFrame.cs index 943961cb9..92eae3c80 100644 --- a/src/ImageProcessor/Imaging/Formats/GifFrame.cs +++ b/src/ImageProcessor/Imaging/Formats/GifFrame.cs @@ -10,6 +10,7 @@ namespace ImageProcessor.Imaging.Formats { + using System; using System.Drawing; /// @@ -25,7 +26,7 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets or sets the delay in milliseconds. /// - public int Delay { get; set; } + public TimeSpan Delay { get; set; } /// /// Gets or sets the x position of the frame. diff --git a/src/ImageProcessor/Imaging/Formats/GifInfo.cs b/src/ImageProcessor/Imaging/Formats/GifInfo.cs index 2fdc1d715..43142971a 100644 --- a/src/ImageProcessor/Imaging/Formats/GifInfo.cs +++ b/src/ImageProcessor/Imaging/Formats/GifInfo.cs @@ -53,6 +53,6 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets or sets the animation length in milliseconds. /// - public int AnimationLength { get; set; } + public double AnimationLength { get; set; } } } \ No newline at end of file diff --git a/src/ImageProcessor/Processors/Resize.cs b/src/ImageProcessor/Processors/Resize.cs index 44fd69b2a..bfab0f5d7 100644 --- a/src/ImageProcessor/Processors/Resize.cs +++ b/src/ImageProcessor/Processors/Resize.cs @@ -83,7 +83,7 @@ namespace ImageProcessor.Processors int.TryParse(this.Settings["MaxWidth"], NumberStyles.Any, CultureInfo.InvariantCulture, out maxWidth); int.TryParse(this.Settings["MaxHeight"], NumberStyles.Any, CultureInfo.InvariantCulture, out maxHeight); - maxSize.Width = maxHeight; + maxSize.Width = maxWidth; maxSize.Height = maxHeight; resizeLayer.MaxSize = maxSize;