diff --git a/src/ImageSharp/Image/ImageFrameCollection.cs b/src/ImageSharp/Image/ImageFrameCollection.cs index bfd8e5e91d..466e2ec392 100644 --- a/src/ImageSharp/Image/ImageFrameCollection.cs +++ b/src/ImageSharp/Image/ImageFrameCollection.cs @@ -91,17 +91,6 @@ namespace SixLabors.ImageSharp this.frames.Add(frame); } - private void ValidateFrameSize(ImageFrame frame) - { - if (this.Count != 0) - { - if (this.RootFrame.Width != frame.Width || this.RootFrame.Height != frame.Height) - { - throw new ArgumentException("Frame must have the same dimensions as the image", nameof(frame)); - } - } - } - /// /// Determines whether the contains the . /// @@ -122,7 +111,7 @@ namespace SixLabors.ImageSharp /// Cannot remove last frame public bool Remove(ImageFrame frame) { - if (this.frames.Count == 1 && this.frames.Contains(frame)) + if (this.Count == 1 && this.frames.Contains(frame)) { throw new InvalidOperationException("Cannot remove last frame"); } @@ -135,5 +124,18 @@ namespace SixLabors.ImageSharp /// IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)this.frames).GetEnumerator(); + + private void ValidateFrameSize(ImageFrame frame) + { + Guard.NotNull(frame, nameof(frame)); + + if (this.Count != 0) + { + if (this.RootFrame.Width != frame.Width || this.RootFrame.Height != frame.Height) + { + throw new ArgumentException("Frame must have the same dimensions as the image", nameof(frame)); + } + } + } } } \ No newline at end of file