From 49369e51b28e3d7d50cb8ea0b3fe26142d82ba13 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 29 May 2016 19:40:07 +1000 Subject: [PATCH] Sanitation [skip ci] Former-commit-id: 75afdcee89a077e71c541a528bef5dc73ba8841b Former-commit-id: cbc78b6631dedb8c625b755d9cb7d7eb6be62d95 Former-commit-id: 442f01311ac24030e7a3894bfe0a431ea5fde2ee --- .editorconfig | 0 src/ImageProcessorCore/Samplers/ImageSamplerExtensions.cs | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/ImageProcessorCore/Samplers/ImageSamplerExtensions.cs b/src/ImageProcessorCore/Samplers/ImageSamplerExtensions.cs index fd9623fc4c..71c40f6c05 100644 --- a/src/ImageProcessorCore/Samplers/ImageSamplerExtensions.cs +++ b/src/ImageProcessorCore/Samplers/ImageSamplerExtensions.cs @@ -40,6 +40,9 @@ namespace ImageProcessorCore.Samplers /// The public static Image Crop(this Image source, int width, int height, Rectangle sourceRectangle, ProgressEventHandler progressHandler = null) { + Guard.MustBeGreaterThan(width, 0, nameof(width)); + Guard.MustBeGreaterThan(height, 0, nameof(height)); + if (sourceRectangle.Width < width || sourceRectangle.Height < height) { // If the source rectangle is smaller than the target perform a @@ -183,6 +186,9 @@ namespace ImageProcessorCore.Samplers height = source.Height * width / source.Width; } + Guard.MustBeGreaterThan(width, 0, nameof(width)); + Guard.MustBeGreaterThan(height, 0, nameof(height)); + Resize processor = new Resize(sampler) { Compand = compand }; processor.OnProgress += progressHandler;