diff --git a/src/ImageProcessor.Playground/Program.cs b/src/ImageProcessor.Playground/Program.cs index a8d0d07ae..c4cd7bc64 100644 --- a/src/ImageProcessor.Playground/Program.cs +++ b/src/ImageProcessor.Playground/Program.cs @@ -50,10 +50,10 @@ namespace ImageProcessor.PlayGround di.Create(); } - // Image mask = Image.FromFile(Path.Combine(resolvedPath, "mask2.png")); - Image overlay = Image.FromFile(Path.Combine(resolvedPath, "monster.png")); + Image mask = Image.FromFile(Path.Combine(resolvedPath, "mask.png")); + Image overlay = Image.FromFile(Path.Combine(resolvedPath, "imageprocessor.128.png")); //FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "monster.png")); - IEnumerable files = GetFilesByExtensions(di, ".png"); + IEnumerable files = GetFilesByExtensions(di, ".jpg"); //IEnumerable files = GetFilesByExtensions(di, ".gif", ".webp", ".bmp", ".jpg", ".png", ".tif"); foreach (FileInfo fileInfo in files) @@ -78,12 +78,11 @@ namespace ImageProcessor.PlayGround //}; // Load, resize, set the format and quality and save an image. imageFactory.Load(inStream) - .Overlay(new ImageLayer - { - Image = overlay, - Size = size, - Opacity = 80 - }) + //.Overlay(new ImageLayer + // { + // Image = overlay, + // Opacity = 50 + // }) //.Alpha(50) //.BackgroundColor(Color.White) //.Resize(new Size((int)(size.Width * 1.1), 0)) @@ -93,7 +92,7 @@ namespace ImageProcessor.PlayGround //.Mask(mask) //.Format(new PngFormat()) //.BackgroundColor(Color.Cyan) - //.ReplaceColor(Color.FromArgb(255, 1, 107, 165), Color.FromArgb(255, 1, 165, 13), 80) + .ReplaceColor(Color.FromArgb(255, 223, 224), Color.FromArgb(121, 188, 255), 128) //.Resize(size) // .Resize(new ResizeLayer(size, ResizeMode.Max)) // .Resize(new ResizeLayer(size, ResizeMode.Stretch)) @@ -107,8 +106,10 @@ namespace ImageProcessor.PlayGround //.Filter(MatrixFilters.HiSatch) //.Pixelate(8) //.GaussianSharpen(10) - .Format(new PngFormat() { IsIndexed = true }) - .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name))); + .Format(new PngFormat()) + //.Format(new PngFormat() { IsIndexed = true }) + //.Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name))); + .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", Path.GetFileNameWithoutExtension(fileInfo.Name) + ".png"))); stopwatch.Stop(); } diff --git a/src/ImageProcessor.Web/Processors/ReplaceColor.cs b/src/ImageProcessor.Web/Processors/ReplaceColor.cs index 286852624..1e7592d0a 100644 --- a/src/ImageProcessor.Web/Processors/ReplaceColor.cs +++ b/src/ImageProcessor.Web/Processors/ReplaceColor.cs @@ -156,7 +156,7 @@ namespace ImageProcessor.Web.Processors fuzziness = int.Parse(match.Value.Split('=')[1], CultureInfo.InvariantCulture); } - return Math.Max(0, Math.Min(100, fuzziness)); + return Math.Max(0, Math.Min(128, fuzziness)); } } } diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index 82fb586f4..1077b2fb6 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -778,7 +778,7 @@ namespace ImageProcessor /// The replacement . /// /// - /// A value between 0 and 100 with which to alter the target detection accuracy. + /// A value between 0 and 128 with which to alter the target detection accuracy. /// /// /// The . @@ -786,7 +786,7 @@ namespace ImageProcessor public ImageFactory ReplaceColor(Color target, Color replacement, int fuzziness = 0) { // Sanitize the input. - if (fuzziness < 0 || fuzziness > 100) + if (fuzziness < 0 || fuzziness > 128) { fuzziness = 0; } diff --git a/src/ImageProcessor/Processors/Overlay.cs b/src/ImageProcessor/Processors/Overlay.cs index 7551a9590..71e7e0e6a 100644 --- a/src/ImageProcessor/Processors/Overlay.cs +++ b/src/ImageProcessor/Processors/Overlay.cs @@ -78,8 +78,8 @@ namespace ImageProcessor.Processors Size size = imageLayer.Size; int width = image.Width; int height = image.Height; - int overlayWidth = size != Size.Empty ? Math.Min(image.Size.Width, size.Width) : image.Size.Width; - int overlayHeight = size != Size.Empty ? Math.Min(image.Size.Height, size.Height) : image.Size.Height; + int overlayWidth = size != Size.Empty ? Math.Min(image.Size.Width, size.Width) : Math.Min(image.Size.Width, overlay.Size.Width); + int overlayHeight = size != Size.Empty ? Math.Min(image.Size.Height, size.Height) : Math.Min(image.Size.Height, overlay.Size.Height); Point? position = imageLayer.Position; int opacity = imageLayer.Opacity; diff --git a/src/ImageProcessor/Processors/ReplaceColor.cs b/src/ImageProcessor/Processors/ReplaceColor.cs index dad33192b..a6f7426f6 100644 --- a/src/ImageProcessor/Processors/ReplaceColor.cs +++ b/src/ImageProcessor/Processors/ReplaceColor.cs @@ -87,11 +87,13 @@ namespace ImageProcessor.Processors using (FastBitmap fastBitmap = new FastBitmap(newImage)) { - Parallel.For( - 0, - height, - y => - { + //Parallel.For( + // 0, + // height, + // y => + // { + for (int y = 0; y < height; y++) + { for (int x = 0; x < width; x++) { // Get the pixel color. @@ -124,7 +126,7 @@ namespace ImageProcessor.Processors } } } - }); + }//); } image.Dispose();